[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210406185458.433826-1-colin.king@canonical.com>
Date: Tue, 6 Apr 2021 19:54:58 +0100
From: Colin King <colin.king@...onical.com>
To: Juerg Haefliger <juergh@...il.com>,
Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>,
"Mark M . Hoffman" <mhoffman@...htlink.com>,
linux-hwmon@...r.kernel.org
Cc: kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] hwmon: (dme1737): Add missing null check on return from platform_get_resource
From: Colin Ian King <colin.king@...onical.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@...onical.com>
---
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,
--
2.30.2
Powered by blists - more mailing lists