From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 400D7C3DA79 for ; Thu, 29 Dec 2022 21:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234023AbiL2Vne (ORCPT ); Thu, 29 Dec 2022 16:43:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiL2Vnb (ORCPT ); Thu, 29 Dec 2022 16:43:31 -0500 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59AA110046 for ; Thu, 29 Dec 2022 13:43:27 -0800 (PST) Received: from [192.168.1.18] ([86.243.100.34]) by smtp.orange.fr with ESMTPA id B0gKp7mDjBicGB0gKpHr5U; Thu, 29 Dec 2022 22:43:25 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 29 Dec 2022 22:43:25 +0100 X-ME-IP: 86.243.100.34 Message-ID: Date: Thu, 29 Dec 2022 22:43:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH] PCI: amlogic: The check for devm_add_action_or_reset's return value added Content-Language: fr, en-US To: Aleksandr Burakov Cc: linux-pci@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Yue Wang , Hanjie Lin , Lorenzo Pieralisi , Rob Herring , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Bjorn Helgaas , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl References: <20221220092137.6527-1-a.burakov@rosalinux.ru> From: Christophe JAILLET In-Reply-To: <20221220092137.6527-1-a.burakov@rosalinux.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 20/12/2022 à 10:21, Aleksandr Burakov a écrit : > The return value of the function devm_add_action_or_reset() was not > checked hence an error code would not be returned. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 9c0ef6d34fdb ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver") > Signed-off-by: Aleksandr Burakov > --- > drivers/pci/controller/dwc/pci-meson.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c > index c1527693bed9..3d82f0b65480 100644 > --- a/drivers/pci/controller/dwc/pci-meson.c > +++ b/drivers/pci/controller/dwc/pci-meson.c > @@ -187,9 +187,13 @@ static inline struct clk *meson_pcie_probe_clock(struct device *dev, > return ERR_PTR(ret); > } > > - devm_add_action_or_reset(dev, > + ret = devm_add_action_or_reset(dev, > (void (*) (void *))clk_disable_unprepare, Hi, using devm_clk_get_enabled() a few lines above would be IMHO much more elegant than these casts. This also saves a few LoC and avoid some other warnings/issues. (see [1]) Such an approach has already been used in [2]. Just my 2c, CJ [1]: https://lore.kernel.org/all/20221118233101.never.215-kees@kernel.org/ [2]: https://lore.kernel.org/all/20221202184525.gonna.423-kees@kernel.org/ > clk); > + if (ret) { > + dev_err(dev, "couldn't reset clk\n"); > + return ERR_PTR(ret); > + } > > return clk; > }