From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
Ludovic Desroches <ludovic.desroches@microchip.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] memory: atmel-sdramc: check of_device_get_match_data() return value
Date: Wed, 7 Apr 2021 18:19:44 +0200 [thread overview]
Message-ID: <YG3boJNqAoNCBeIB@piout.net> (raw)
In-Reply-To: <20210407154447.70540-1-krzysztof.kozlowski@canonical.com>
Hi,
On 07/04/2021 17:44:47+0200, Krzysztof Kozlowski wrote:
> If the driver is probed, the of_device_get_match_data() should not
> return NULL, however for sanity check its return value.
>
As you say, there is no way this will ever be the case, I don't see the
point of checking the return value, this adds 12 bytes for nothing...
Maybe coverity should be fixed as there are many drivers making the same
(true) assumption and I don't think this is worth the churn.
> Addresses-Coverity: Dereference null return value
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
> drivers/memory/atmel-sdramc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c
> index 9c49d00c2a96..e09b2617f63d 100644
> --- a/drivers/memory/atmel-sdramc.c
> +++ b/drivers/memory/atmel-sdramc.c
> @@ -45,6 +45,8 @@ static int atmel_ramc_probe(struct platform_device *pdev)
> struct clk *clk;
>
> caps = of_device_get_match_data(&pdev->dev);
> + if (!caps)
> + return -EINVAL;
>
> if (caps->has_ddrck) {
> clk = devm_clk_get(&pdev->dev, "ddrck");
> --
> 2.25.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2021-04-07 16:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 15:44 [PATCH] memory: atmel-sdramc: check of_device_get_match_data() return value Krzysztof Kozlowski
2021-04-07 16:19 ` Alexandre Belloni [this message]
2021-04-07 16:55 ` Krzysztof Kozlowski
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=YG3boJNqAoNCBeIB@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=krzysztof.kozlowski@canonical.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=nicolas.ferre@microchip.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;
as well as URLs for NNTP newsgroup(s).