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 04/20] hwmon: (f71805f) 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: e53004e20a58 ("[PATCH] hwmon: New f71805f driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/hwmon/f71805f.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 7f20edb0677c..7d88e7647074 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -1384,6 +1384,8 @@ static int f71805f_probe(struct platform_device *pdev)
return -ENOMEM;

res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -EINVAL;
if (!devm_request_region(&pdev->dev, res->start + ADDR_REG_OFFSET, 2,
DRVNAME)) {
dev_err(&pdev->dev, "Failed to request region 0x%lx-0x%lx\n",
--
2.25.1
\
 
 \ /
  Last update: 2022-04-22 11:01    [W:0.433 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site