From: Guenter Roeck <linux@roeck-us.net>
To: Colin King <colin.king@canonical.com>
Cc: Juerg Haefliger <juergh@gmail.com>,
Jean Delvare <jdelvare@suse.com>,
"Mark M . Hoffman" <mhoffman@lightlink.com>,
linux-hwmon@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (dme1737): Add missing null check on return from platform_get_resource
Date: Fri, 9 Apr 2021 16:08:37 -0700 [thread overview]
Message-ID: <20210409230837.GA69920@roeck-us.net> (raw)
In-Reply-To: <20210406185458.433826-1-colin.king@canonical.com>
On Tue, Apr 06, 2021 at 07:54:58PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The call to platform_get_resource can potentially return a NULL pointer
> on failure, so add this check and return -EINVAL if it fails.
>
> Addresses-Coverity: ("Dereference null return")
> Fixes: e95c237d78c0 ("hwmon: (dme1737) Add sch311x support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Not really sure what to do with this; it is a false positive.
The resource is always set by the instantiating code (in the same
driver). Adding an error check just to make coverity happy seems
like a waste. Maybe we should introduce the equivalent of
devm_ioremap_resource() for IORESOURCE_IO.
Guenter
> ---
> drivers/hwmon/dme1737.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
> index c1e4cfb40c3d..a2157872e126 100644
> --- a/drivers/hwmon/dme1737.c
> +++ b/drivers/hwmon/dme1737.c
> @@ -2633,6 +2633,8 @@ static int dme1737_isa_probe(struct platform_device *pdev)
> int err;
>
> res = platform_get_resource(pdev, IORESOURCE_IO, 0);
> + if (!res)
> + return -EINVAL;
> if (!devm_request_region(dev, res->start, DME1737_EXTENT, "dme1737")) {
> dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
> (unsigned short)res->start,
prev parent reply other threads:[~2021-04-09 23:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 18:54 [PATCH] hwmon: (dme1737): Add missing null check on return from platform_get_resource Colin King
2021-04-09 23:08 ` Guenter Roeck [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=20210409230837.GA69920@roeck-us.net \
--to=linux@roeck-us.net \
--cc=colin.king@canonical.com \
--cc=jdelvare@suse.com \
--cc=juergh@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhoffman@lightlink.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