mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Aleksandr Burakov <a.burakov@rosalinux.ru>
Cc: linux-pci@vger.kernel.org, linux-amlogic@lists.infradead.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	"Yue Wang" <yue.wang@amlogic.com>,
	"Hanjie Lin" <hanjie.lin@amlogic.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Kevin Hilman" <khilman@baylibre.com>,
	"Jerome Brunet" <jbrunet@baylibre.com>,
	"Martin Blumenstingl" <martin.blumenstingl@googlemail.com>
Subject: Re: [PATCH] PCI: amlogic: The check for devm_add_action_or_reset's return value added
Date: Thu, 29 Dec 2022 22:43:19 +0100	[thread overview]
Message-ID: <c0deb523-0458-5422-bed5-ee104ca7c479@wanadoo.fr> (raw)
In-Reply-To: <20221220092137.6527-1-a.burakov@rosalinux.ru>

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 <a.burakov@rosalinux.ru>
> ---
>   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;
>   }


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      parent reply	other threads:[~2022-12-29 21:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20  9:21 Aleksandr Burakov
2022-12-29 19:43 ` Bjorn Helgaas
2022-12-29 21:43 ` Christophe JAILLET [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c0deb523-0458-5422-bed5-ee104ca7c479@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=a.burakov@rosalinux.ru \
    --cc=bhelgaas@google.com \
    --cc=hanjie.lin@amlogic.com \
    --cc=jbrunet@baylibre.com \
    --cc=khilman@baylibre.com \
    --cc=kw@linux.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lvc-project@linuxtesting.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neil.armstrong@linaro.org \
    --cc=robh@kernel.org \
    --cc=yue.wang@amlogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®