lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220422091207.4034406-6-yangyingliang@huawei.com>
Date:   Fri, 22 Apr 2022 17:11:52 +0800
From:   Yang Yingliang <yangyingliang@...wei.com>
To:     <linux-kernel@...r.kernel.org>, <linux-hwmon@...r.kernel.org>
CC:     <linux@...ck-us.net>, <jdelvare@...e.com>
Subject: [PATCH 05/20] hwmon: (f71882fg) check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: 45fb366940d5 ("hwmon: add support for Fintek F71882FG and F71883FG")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
 drivers/hwmon/f71882fg.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 938a8b9ec70d..33aec2a35e57 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -2336,13 +2336,17 @@ static int f71882fg_probe(struct platform_device *pdev)
 	int err, i;
 	int size;
 	u8 start_reg, reg;
+	struct resource *res;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct f71882fg_data),
 			    GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
+	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
+	data->addr = res->start;
 	data->type = sio_data->type;
 	data->temp_start =
 	    (data->type == f71858fg || data->type == f8000 ||
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ