mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-hwmon@vger.kernel.org>
Cc: <linux@roeck-us.net>, <jdelvare@suse.com>
Subject: [PATCH 01/20] hwmon: (abituguru) check return value after calling platform_get_resource()
Date: Fri, 22 Apr 2022 17:11:48 +0800	[thread overview]
Message-ID: <20220422091207.4034406-2-yangyingliang@huawei.com> (raw)
In-Reply-To: <20220422091207.4034406-1-yangyingliang@huawei.com>

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

Fixes: f2b84bbcebfd ("[PATCH] abituguru: New hardware monitoring driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/abituguru.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c
index 681f0623868f..58595567440c 100644
--- a/drivers/hwmon/abituguru.c
+++ b/drivers/hwmon/abituguru.c
@@ -1259,6 +1259,7 @@ static int abituguru_probe(struct platform_device *pdev)
 	struct abituguru_data *data;
 	int i, j, used, sysfs_names_free, sysfs_attr_i, res = -ENODEV;
 	char *sysfs_filename;
+	struct resource *r;
 
 	/*
 	 * El weirdo probe order, to keep the sysfs order identical to the
@@ -1273,7 +1274,10 @@ static int abituguru_probe(struct platform_device *pdev)
 	if (!data)
 		return -ENOMEM;
 
-	data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
+	r = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!r)
+		return -EINVAL;
+	data->addr = r->start;
 	mutex_init(&data->update_lock);
 	platform_set_drvdata(pdev, data);
 
-- 
2.25.1


  reply	other threads:[~2022-04-22  9:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22  9:11 [PATCH 00/20] hwmon: " Yang Yingliang
2022-04-22  9:11 ` Yang Yingliang [this message]
2022-04-22  9:11 ` [PATCH 02/20] hwmon: (abituguru3) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 03/20] hwmon: (dme1737) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 04/20] hwmon: (f71805f) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 05/20] hwmon: (f71882fg) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 06/20] hwmon: (it87) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 07/20] hwmon: (lm78) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 08/20] hwmon: (nct6683) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 09/20] hwmon: (nct6775) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 10/20] hwmon: (sch5627) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 11/20] hwmon: (sch5636) " Yang Yingliang
2022-04-22  9:11 ` [PATCH 12/20] hwmon: (sis5595) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 13/20] hwmon: (smsc47b397) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 14/20] hwmon: (smsc47m1) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 15/20] hwmon: (via686a) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 16/20] hwmon: (vt1211) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 17/20] hwmon: (vt8231) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 18/20] hwmon: (w83627ehf) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 19/20] hwmon: (w83627hf) " Yang Yingliang
2022-04-22  9:12 ` [PATCH 20/20] hwmon: (w83781d) " Yang Yingliang
2022-04-22 13:27 ` [PATCH 00/20] hwmon: " Guenter Roeck
2022-04-24  3:35   ` Yang Yingliang
2022-04-24  4:54     ` Guenter Roeck
2022-04-24  6:20       ` Yang Yingliang

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=20220422091207.4034406-2-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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

all inboxes | Powered by JetHome®