lkml.org 
[lkml]   [2022]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 15/20] hwmon: (via686a) check return value after calling platform_get_resource()
Date
It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: 2ec342e68453 ("hwmon/via686a: Convert to a platform driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/hwmon/via686a.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 55634110c2f9..f4e0a56498f8 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -671,6 +671,8 @@ static int via686a_probe(struct platform_device *pdev)

/* Reserve the ISA region */
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -EINVAL;
if (!devm_request_region(&pdev->dev, res->start, VIA686A_EXTENT,
via686a_driver.driver.name)) {
dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
--
2.25.1
\
 
 \ /
  Last update: 2022-04-22 11:01    [W:1.483 / U:3.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site