All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/20] hwmon: check return value after calling platform_get_resource()
@ 2022-04-22  9:11 Yang Yingliang
  2022-04-22  9:11 ` [PATCH 01/20] hwmon: (abituguru) " Yang Yingliang
                   ` (20 more replies)
  0 siblings, 21 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

This patcheset add check after calling platform_get_resource to avoid null-ptr-deref
in drivers/hwmon/.

Yang Yingliang (20):
  hwmon: (abituguru) check return value after calling
    platform_get_resource()
  hwmon: (abituguru3) check return value after calling
    platform_get_resource()
  hwmon: (dme1737) check return value after calling
    platform_get_resource()
  hwmon: (f71805f) check return value after calling
    platform_get_resource()
  hwmon: (f71882fg) check return value after calling
    platform_get_resource()
  hwmon: (it87) check return value after calling platform_get_resource()
  hwmon: (lm78) check return value after calling platform_get_resource()
  hwmon: (nct6683) check return value after calling
    platform_get_resource()
  hwmon: (nct6775) check return value after calling
    platform_get_resource()
  hwmon: (sch5627) check return value after calling
    platform_get_resource()
  hwmon: (sch5636) check return value after calling
    platform_get_resource()
  hwmon: (sis5595) check return value after calling
    platform_get_resource()
  hwmon: (smsc47b397) check return value after calling
    platform_get_resource()
  hwmon: (smsc47m1) check return value after calling
    platform_get_resource()
  hwmon: (via686a) check return value after calling
    platform_get_resource()
  hwmon: (vt1211) check return value after calling
    platform_get_resource()
  hwmon: (vt8231) check return value after calling
    platform_get_resource()
  hwmon: (w83627ehf) check return value after calling
    platform_get_resource()
  hwmon: (w83627hf) check return value after calling
    platform_get_resource()
  hwmon: (w83781d) check return value after calling
    platform_get_resource()

 drivers/hwmon/abituguru.c  | 6 +++++-
 drivers/hwmon/abituguru3.c | 6 +++++-
 drivers/hwmon/dme1737.c    | 2 ++
 drivers/hwmon/f71805f.c    | 2 ++
 drivers/hwmon/f71882fg.c   | 6 +++++-
 drivers/hwmon/it87.c       | 2 ++
 drivers/hwmon/lm78.c       | 2 ++
 drivers/hwmon/nct6683.c    | 2 ++
 drivers/hwmon/nct6775.c    | 2 ++
 drivers/hwmon/sch5627.c    | 6 +++++-
 drivers/hwmon/sch5636.c    | 6 +++++-
 drivers/hwmon/sis5595.c    | 2 ++
 drivers/hwmon/smsc47b397.c | 2 ++
 drivers/hwmon/smsc47m1.c   | 2 ++
 drivers/hwmon/via686a.c    | 2 ++
 drivers/hwmon/vt1211.c     | 2 ++
 drivers/hwmon/vt8231.c     | 2 ++
 drivers/hwmon/w83627ehf.c  | 2 ++
 drivers/hwmon/w83627hf.c   | 2 ++
 drivers/hwmon/w83781d.c    | 2 ++
 20 files changed, 55 insertions(+), 5 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 01/20] hwmon: (abituguru) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 02/20] hwmon: (abituguru3) " Yang Yingliang
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 02/20] hwmon: (abituguru3) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
  2022-04-22  9:11 ` [PATCH 01/20] hwmon: (abituguru) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 03/20] hwmon: (dme1737) " Yang Yingliang
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: 3faa1ffb4f4b ("hwmon: Add support for newer uGuru's")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/abituguru3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index 8229ad30c909..7abce72f3b48 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -964,13 +964,17 @@ static int abituguru3_probe(struct platform_device *pdev)
 	char *sysfs_filename;
 	u8 buf[2];
 	u16 id;
+	struct resource *r;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct abituguru3_data),
 			    GFP_KERNEL);
 	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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 03/20] hwmon: (dme1737) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
  2022-04-22  9:11 ` [PATCH 01/20] hwmon: (abituguru) " Yang Yingliang
  2022-04-22  9:11 ` [PATCH 02/20] hwmon: (abituguru3) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 04/20] hwmon: (f71805f) " Yang Yingliang
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: e95c237d78c0 ("hwmon: (dme1737) Add sch311x support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/dme1737.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index e3ad4c2d0038..90281a016118 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.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 04/20] hwmon: (f71805f) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (2 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 03/20] hwmon: (dme1737) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 05/20] hwmon: (f71882fg) " Yang Yingliang
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 05/20] hwmon: (f71882fg) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (3 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 04/20] hwmon: (f71805f) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 06/20] hwmon: (it87) " Yang Yingliang
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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@huawei.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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 06/20] hwmon: (it87) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (4 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 05/20] hwmon: (f71882fg) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 07/20] hwmon: (lm78) " Yang Yingliang
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 0e543dbe0a6b..66e465ae6ecc 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -3041,6 +3041,8 @@ static int it87_probe(struct platform_device *pdev)
 	struct device *hwmon_dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_region(&pdev->dev, res->start, IT87_EC_EXTENT,
 				 DRVNAME)) {
 		dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 07/20] hwmon: (lm78) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (5 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 06/20] hwmon: (it87) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 08/20] hwmon: (nct6683) " Yang Yingliang
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: c40769fee13c ("hwmon/lm78: No longer use i2c-isa")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/lm78.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 5e129cbec1cb..71c2a1bc75cc 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -792,6 +792,8 @@ static int lm78_isa_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(dev, res->start + LM78_ADDR_REG_OFFSET,
 				 2, "lm78"))
 		return -EBUSY;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 08/20] hwmon: (nct6683) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (6 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 07/20] hwmon: (lm78) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 09/20] hwmon: (nct6775) " Yang Yingliang
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: 41082d66bfd6 ("hwmon: Driver for NCT6683D")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/nct6683.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
index 6a9f420e7d32..12cac70ff493 100644
--- a/drivers/hwmon/nct6683.c
+++ b/drivers/hwmon/nct6683.c
@@ -1197,6 +1197,8 @@ static int nct6683_probe(struct platform_device *pdev)
 	char build[16];
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_region(dev, res->start, IOREGION_LENGTH, DRVNAME))
 		return -EBUSY;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 09/20] hwmon: (nct6775) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (7 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 08/20] hwmon: (nct6683) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 10/20] hwmon: (sch5627) " Yang Yingliang
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: 9de2e2e84e7d ("hwmon: Driver for Nuvoton NCT6775F, NCT6776F, and NCT6779D")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/nct6775.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 2b91f7e05126..d7479ba9636c 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -4027,6 +4027,8 @@ static int nct6775_probe(struct platform_device *pdev)
 
 	if (sio_data->access == access_direct) {
 		res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+		if (!res)
+			return -EINVAL;
 		if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
 					 DRVNAME))
 			return -EBUSY;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 10/20] hwmon: (sch5627) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (8 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 09/20] hwmon: (nct6775) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 11/20] hwmon: (sch5636) " Yang Yingliang
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: a98d506c08ff ("hwmon: New driver for SMSC SCH5627")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/sch5627.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c
index 25fbbd4c9a2b..1294624a3ed7 100644
--- a/drivers/hwmon/sch5627.c
+++ b/drivers/hwmon/sch5627.c
@@ -423,13 +423,17 @@ static int sch5627_probe(struct platform_device *pdev)
 	struct sch5627_data *data;
 	struct device *hwmon_dev;
 	int err, build_code, build_id, hwmon_rev, val;
+	struct resource *res;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct sch5627_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;
 	mutex_init(&data->update_lock);
 	platform_set_drvdata(pdev, data);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 11/20] hwmon: (sch5636) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (9 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 10/20] hwmon: (sch5627) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:11 ` [PATCH 12/20] hwmon: (sis5595) " Yang Yingliang
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: 0772a6407939 ("hwmon: New driver sch5636")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/sch5636.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/sch5636.c b/drivers/hwmon/sch5636.c
index 269757bc3a9e..6fc471168af8 100644
--- a/drivers/hwmon/sch5636.c
+++ b/drivers/hwmon/sch5636.c
@@ -394,13 +394,17 @@ static int sch5636_probe(struct platform_device *pdev)
 	struct sch5636_data *data;
 	int i, err, val, revision[2];
 	char id[4];
+	struct resource *res;
 
 	data = devm_kzalloc(&pdev->dev, sizeof(struct sch5636_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;
 	mutex_init(&data->update_lock);
 	platform_set_drvdata(pdev, data);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 12/20] hwmon: (sis5595) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (10 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 11/20] hwmon: (sch5636) " Yang Yingliang
@ 2022-04-22  9:11 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 13/20] hwmon: (smsc47b397) " Yang Yingliang
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:11 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 018cb5a7651f..b664c306d087 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -579,6 +579,8 @@ static int sis5595_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, SIS5595_EXTENT,
 				 sis5595_driver.driver.name))
 		return -EBUSY;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 13/20] hwmon: (smsc47b397) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (11 preceding siblings ...)
  2022-04-22  9:11 ` [PATCH 12/20] hwmon: (sis5595) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 14/20] hwmon: (smsc47m1) " Yang Yingliang
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index c26d6eae0e4e..07c04780f871 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -224,6 +224,8 @@ static int smsc47b397_probe(struct platform_device *pdev)
 	struct resource *res;
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_region(dev, res->start, SMSC_EXTENT,
 				 smsc47b397_driver.driver.name)) {
 		dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 14/20] hwmon: (smsc47m1) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (12 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 13/20] hwmon: (smsc47b397) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 15/20] hwmon: (via686a) " Yang Yingliang
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 37531b5c8254..0dc432af7b18 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -719,6 +719,8 @@ static int __init smsc47m1_probe(struct platform_device *pdev)
 	};
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	err = smsc47m1_handle_resources(res->start, sio_data->type,
 					REQUEST, dev);
 	if (err < 0)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 15/20] hwmon: (via686a) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (13 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 14/20] hwmon: (smsc47m1) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 16/20] hwmon: (vt1211) " Yang Yingliang
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 16/20] hwmon: (vt1211) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (14 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 15/20] hwmon: (via686a) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 17/20] hwmon: (vt8231) " Yang Yingliang
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: ab41319eab3b ("hwmon: New driver for the VIA VT1211")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/vt1211.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index 4a5e911d26eb..4b1448e7f1c0 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -1152,6 +1152,8 @@ static int vt1211_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_region(dev, res->start, resource_size(res),
 				 DRVNAME)) {
 		dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 17/20] hwmon: (vt8231) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (15 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 16/20] hwmon: (vt1211) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 18/20] hwmon: (w83627ehf) " Yang Yingliang
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 03275ac8ba72..394ba989b7ae 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -783,6 +783,8 @@ static int vt8231_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, VT8231_EXTENT,
 				 vt8231_driver.driver.name)) {
 		dev_err(&pdev->dev, "Region 0x%lx-0x%lx already in use!\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 18/20] hwmon: (w83627ehf) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (16 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 17/20] hwmon: (vt8231) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22  9:12 ` [PATCH 19/20] hwmon: (w83627hf) " Yang Yingliang
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index af89b32a93a5..5d5a7a66d420 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -1703,6 +1703,8 @@ static int __init w83627ehf_probe(struct platform_device *pdev)
 	struct device *hwmon_dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_region(dev, res->start, IOREGION_LENGTH, DRVNAME))
 		return -EBUSY;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 19/20] hwmon: (w83627hf) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (17 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 18/20] hwmon: (w83627ehf) " Yang Yingliang
@ 2022-04-22  9:12 ` 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
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

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

diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 9be277156ed2..9d370d73d39d 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -1407,6 +1407,8 @@ static int w83627hf_probe(struct platform_device *pdev)
 	};
 
 	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_region(dev, res->start, WINB_REGION_SIZE, DRVNAME)) {
 		dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
 			(unsigned long)res->start,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH 20/20] hwmon: (w83781d) check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (18 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 19/20] hwmon: (w83627hf) " Yang Yingliang
@ 2022-04-22  9:12 ` Yang Yingliang
  2022-04-22 13:27 ` [PATCH 00/20] hwmon: " Guenter Roeck
  20 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-22  9:12 UTC (permalink / raw)
  To: linux-kernel, linux-hwmon; +Cc: linux, jdelvare

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

Fixes: 7666c13c627f ("hwmon/w83781d: No longer use i2c-isa")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/hwmon/w83781d.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index b3579721265f..4fe6eec02570 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1767,6 +1767,8 @@ w83781d_isa_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 + W83781D_ADDR_REG_OFFSET, 2,
 				 "w83781d"))
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/20] hwmon: check return value after calling platform_get_resource()
  2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
                   ` (19 preceding siblings ...)
  2022-04-22  9:12 ` [PATCH 20/20] hwmon: (w83781d) " Yang Yingliang
@ 2022-04-22 13:27 ` Guenter Roeck
  2022-04-24  3:35   ` Yang Yingliang
  20 siblings, 1 reply; 25+ messages in thread
From: Guenter Roeck @ 2022-04-22 13:27 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, linux-hwmon; +Cc: jdelvare

On 4/22/22 02:11, Yang Yingliang wrote:
> This patcheset add check after calling platform_get_resource to avoid null-ptr-deref
> in drivers/hwmon/.
> 
> Yang Yingliang (20):
>    hwmon: (abituguru) check return value after calling
>      platform_get_resource()
>    hwmon: (abituguru3) check return value after calling
>      platform_get_resource()
>    hwmon: (dme1737) check return value after calling
>      platform_get_resource()
>    hwmon: (f71805f) check return value after calling
>      platform_get_resource()
>    hwmon: (f71882fg) check return value after calling
>      platform_get_resource()
>    hwmon: (it87) check return value after calling platform_get_resource()
>    hwmon: (lm78) check return value after calling platform_get_resource()
>    hwmon: (nct6683) check return value after calling
>      platform_get_resource()
>    hwmon: (nct6775) check return value after calling
>      platform_get_resource()
>    hwmon: (sch5627) check return value after calling
>      platform_get_resource()
>    hwmon: (sch5636) check return value after calling
>      platform_get_resource()
>    hwmon: (sis5595) check return value after calling
>      platform_get_resource()
>    hwmon: (smsc47b397) check return value after calling
>      platform_get_resource()
>    hwmon: (smsc47m1) check return value after calling
>      platform_get_resource()
>    hwmon: (via686a) check return value after calling
>      platform_get_resource()
>    hwmon: (vt1211) check return value after calling
>      platform_get_resource()
>    hwmon: (vt8231) check return value after calling
>      platform_get_resource()
>    hwmon: (w83627ehf) check return value after calling
>      platform_get_resource()
>    hwmon: (w83627hf) check return value after calling
>      platform_get_resource()
>    hwmon: (w83781d) check return value after calling
>      platform_get_resource()
> 
>   drivers/hwmon/abituguru.c  | 6 +++++-
>   drivers/hwmon/abituguru3.c | 6 +++++-
>   drivers/hwmon/dme1737.c    | 2 ++
>   drivers/hwmon/f71805f.c    | 2 ++
>   drivers/hwmon/f71882fg.c   | 6 +++++-
>   drivers/hwmon/it87.c       | 2 ++
>   drivers/hwmon/lm78.c       | 2 ++
>   drivers/hwmon/nct6683.c    | 2 ++
>   drivers/hwmon/nct6775.c    | 2 ++
>   drivers/hwmon/sch5627.c    | 6 +++++-
>   drivers/hwmon/sch5636.c    | 6 +++++-
>   drivers/hwmon/sis5595.c    | 2 ++
>   drivers/hwmon/smsc47b397.c | 2 ++
>   drivers/hwmon/smsc47m1.c   | 2 ++
>   drivers/hwmon/via686a.c    | 2 ++
>   drivers/hwmon/vt1211.c     | 2 ++
>   drivers/hwmon/vt8231.c     | 2 ++
>   drivers/hwmon/w83627ehf.c  | 2 ++
>   drivers/hwmon/w83627hf.c   | 2 ++
>   drivers/hwmon/w83781d.c    | 2 ++
>   20 files changed, 55 insertions(+), 5 deletions(-)
> 

This series solves a problem which does not exist in reality and is only theoretic.
The devices are instantiated from their init functions which always adds the resource.
Please do not submit such patches.

Guenter

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/20] hwmon: check return value after calling platform_get_resource()
  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
  0 siblings, 1 reply; 25+ messages in thread
From: Yang Yingliang @ 2022-04-24  3:35 UTC (permalink / raw)
  To: Guenter Roeck, linux-kernel, linux-hwmon; +Cc: jdelvare

Hi,

On 2022/4/22 21:27, Guenter Roeck wrote:
> On 4/22/22 02:11, Yang Yingliang wrote:
>> This patcheset add check after calling platform_get_resource to avoid 
>> null-ptr-deref
>> in drivers/hwmon/.
>>
>> Yang Yingliang (20):
>>    hwmon: (abituguru) check return value after calling
>>      platform_get_resource()
>>    hwmon: (abituguru3) check return value after calling
>>      platform_get_resource()
>>    hwmon: (dme1737) check return value after calling
>>      platform_get_resource()
>>    hwmon: (f71805f) check return value after calling
>>      platform_get_resource()
>>    hwmon: (f71882fg) check return value after calling
>>      platform_get_resource()
>>    hwmon: (it87) check return value after calling 
>> platform_get_resource()
>>    hwmon: (lm78) check return value after calling 
>> platform_get_resource()
>>    hwmon: (nct6683) check return value after calling
>>      platform_get_resource()
>>    hwmon: (nct6775) check return value after calling
>>      platform_get_resource()
>>    hwmon: (sch5627) check return value after calling
>>      platform_get_resource()
>>    hwmon: (sch5636) check return value after calling
>>      platform_get_resource()
>>    hwmon: (sis5595) check return value after calling
>>      platform_get_resource()
>>    hwmon: (smsc47b397) check return value after calling
>>      platform_get_resource()
>>    hwmon: (smsc47m1) check return value after calling
>>      platform_get_resource()
>>    hwmon: (via686a) check return value after calling
>>      platform_get_resource()
>>    hwmon: (vt1211) check return value after calling
>>      platform_get_resource()
>>    hwmon: (vt8231) check return value after calling
>>      platform_get_resource()
>>    hwmon: (w83627ehf) check return value after calling
>>      platform_get_resource()
>>    hwmon: (w83627hf) check return value after calling
>>      platform_get_resource()
>>    hwmon: (w83781d) check return value after calling
>>      platform_get_resource()
>>
>>   drivers/hwmon/abituguru.c  | 6 +++++-
>>   drivers/hwmon/abituguru3.c | 6 +++++-
>>   drivers/hwmon/dme1737.c    | 2 ++
>>   drivers/hwmon/f71805f.c    | 2 ++
>>   drivers/hwmon/f71882fg.c   | 6 +++++-
>>   drivers/hwmon/it87.c       | 2 ++
>>   drivers/hwmon/lm78.c       | 2 ++
>>   drivers/hwmon/nct6683.c    | 2 ++
>>   drivers/hwmon/nct6775.c    | 2 ++
>>   drivers/hwmon/sch5627.c    | 6 +++++-
>>   drivers/hwmon/sch5636.c    | 6 +++++-
>>   drivers/hwmon/sis5595.c    | 2 ++
>>   drivers/hwmon/smsc47b397.c | 2 ++
>>   drivers/hwmon/smsc47m1.c   | 2 ++
>>   drivers/hwmon/via686a.c    | 2 ++
>>   drivers/hwmon/vt1211.c     | 2 ++
>>   drivers/hwmon/vt8231.c     | 2 ++
>>   drivers/hwmon/w83627ehf.c  | 2 ++
>>   drivers/hwmon/w83627hf.c   | 2 ++
>>   drivers/hwmon/w83781d.c    | 2 ++
>>   20 files changed, 55 insertions(+), 5 deletions(-)
>>
>
> This series solves a problem which does not exist in reality and is 
> only theoretic.
> The devices are instantiated from their init functions which always 
> adds the resource.
> Please do not submit such patches.
As you said the resource will be add in init functions, I checked these 
drivers, the driver
sch5627 and sch5636 won't add resource, so need I send patches to fix 
these drivers ?

Thanks,
Yang
>
> Guenter
> .

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/20] hwmon: check return value after calling platform_get_resource()
  2022-04-24  3:35   ` Yang Yingliang
@ 2022-04-24  4:54     ` Guenter Roeck
  2022-04-24  6:20       ` Yang Yingliang
  0 siblings, 1 reply; 25+ messages in thread
From: Guenter Roeck @ 2022-04-24  4:54 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, linux-hwmon; +Cc: jdelvare

On 4/23/22 20:35, Yang Yingliang wrote:
> Hi,
> 
> On 2022/4/22 21:27, Guenter Roeck wrote:
>> On 4/22/22 02:11, Yang Yingliang wrote:
>>> This patcheset add check after calling platform_get_resource to avoid null-ptr-deref
>>> in drivers/hwmon/.
>>>
>>> Yang Yingliang (20):
>>>    hwmon: (abituguru) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (abituguru3) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (dme1737) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (f71805f) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (f71882fg) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (it87) check return value after calling platform_get_resource()
>>>    hwmon: (lm78) check return value after calling platform_get_resource()
>>>    hwmon: (nct6683) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (nct6775) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (sch5627) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (sch5636) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (sis5595) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (smsc47b397) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (smsc47m1) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (via686a) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (vt1211) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (vt8231) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (w83627ehf) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (w83627hf) check return value after calling
>>>      platform_get_resource()
>>>    hwmon: (w83781d) check return value after calling
>>>      platform_get_resource()
>>>
>>>   drivers/hwmon/abituguru.c  | 6 +++++-
>>>   drivers/hwmon/abituguru3.c | 6 +++++-
>>>   drivers/hwmon/dme1737.c    | 2 ++
>>>   drivers/hwmon/f71805f.c    | 2 ++
>>>   drivers/hwmon/f71882fg.c   | 6 +++++-
>>>   drivers/hwmon/it87.c       | 2 ++
>>>   drivers/hwmon/lm78.c       | 2 ++
>>>   drivers/hwmon/nct6683.c    | 2 ++
>>>   drivers/hwmon/nct6775.c    | 2 ++
>>>   drivers/hwmon/sch5627.c    | 6 +++++-
>>>   drivers/hwmon/sch5636.c    | 6 +++++-
>>>   drivers/hwmon/sis5595.c    | 2 ++
>>>   drivers/hwmon/smsc47b397.c | 2 ++
>>>   drivers/hwmon/smsc47m1.c   | 2 ++
>>>   drivers/hwmon/via686a.c    | 2 ++
>>>   drivers/hwmon/vt1211.c     | 2 ++
>>>   drivers/hwmon/vt8231.c     | 2 ++
>>>   drivers/hwmon/w83627ehf.c  | 2 ++
>>>   drivers/hwmon/w83627hf.c   | 2 ++
>>>   drivers/hwmon/w83781d.c    | 2 ++
>>>   20 files changed, 55 insertions(+), 5 deletions(-)
>>>
>>
>> This series solves a problem which does not exist in reality and is only theoretic.
>> The devices are instantiated from their init functions which always adds the resource.
>> Please do not submit such patches.
> As you said the resource will be add in init functions, I checked these drivers, the driver
> sch5627 and sch5636 won't add resource, so need I send patches to fix these drivers ?
> 
You might want to read the code more carefully. The drivers are instantiated
from drivers/hwmon/sch56xx-common.c which does add the resource.

Guenter


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH 00/20] hwmon: check return value after calling platform_get_resource()
  2022-04-24  4:54     ` Guenter Roeck
@ 2022-04-24  6:20       ` Yang Yingliang
  0 siblings, 0 replies; 25+ messages in thread
From: Yang Yingliang @ 2022-04-24  6:20 UTC (permalink / raw)
  To: Guenter Roeck, linux-kernel, linux-hwmon; +Cc: jdelvare


On 2022/4/24 12:54, Guenter Roeck wrote:
> On 4/23/22 20:35, Yang Yingliang wrote:
>> Hi,
>>
>> On 2022/4/22 21:27, Guenter Roeck wrote:
>>> On 4/22/22 02:11, Yang Yingliang wrote:
>>>> This patcheset add check after calling platform_get_resource to 
>>>> avoid null-ptr-deref
>>>> in drivers/hwmon/.
>>>>
>>>> Yang Yingliang (20):
>>>>    hwmon: (abituguru) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (abituguru3) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (dme1737) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (f71805f) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (f71882fg) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (it87) check return value after calling 
>>>> platform_get_resource()
>>>>    hwmon: (lm78) check return value after calling 
>>>> platform_get_resource()
>>>>    hwmon: (nct6683) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (nct6775) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (sch5627) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (sch5636) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (sis5595) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (smsc47b397) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (smsc47m1) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (via686a) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (vt1211) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (vt8231) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (w83627ehf) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (w83627hf) check return value after calling
>>>>      platform_get_resource()
>>>>    hwmon: (w83781d) check return value after calling
>>>>      platform_get_resource()
>>>>
>>>>   drivers/hwmon/abituguru.c  | 6 +++++-
>>>>   drivers/hwmon/abituguru3.c | 6 +++++-
>>>>   drivers/hwmon/dme1737.c    | 2 ++
>>>>   drivers/hwmon/f71805f.c    | 2 ++
>>>>   drivers/hwmon/f71882fg.c   | 6 +++++-
>>>>   drivers/hwmon/it87.c       | 2 ++
>>>>   drivers/hwmon/lm78.c       | 2 ++
>>>>   drivers/hwmon/nct6683.c    | 2 ++
>>>>   drivers/hwmon/nct6775.c    | 2 ++
>>>>   drivers/hwmon/sch5627.c    | 6 +++++-
>>>>   drivers/hwmon/sch5636.c    | 6 +++++-
>>>>   drivers/hwmon/sis5595.c    | 2 ++
>>>>   drivers/hwmon/smsc47b397.c | 2 ++
>>>>   drivers/hwmon/smsc47m1.c   | 2 ++
>>>>   drivers/hwmon/via686a.c    | 2 ++
>>>>   drivers/hwmon/vt1211.c     | 2 ++
>>>>   drivers/hwmon/vt8231.c     | 2 ++
>>>>   drivers/hwmon/w83627ehf.c  | 2 ++
>>>>   drivers/hwmon/w83627hf.c   | 2 ++
>>>>   drivers/hwmon/w83781d.c    | 2 ++
>>>>   20 files changed, 55 insertions(+), 5 deletions(-)
>>>>
>>>
>>> This series solves a problem which does not exist in reality and is 
>>> only theoretic.
>>> The devices are instantiated from their init functions which always 
>>> adds the resource.
>>> Please do not submit such patches.
>> As you said the resource will be add in init functions, I checked 
>> these drivers, the driver
>> sch5627 and sch5636 won't add resource, so need I send patches to fix 
>> these drivers ?
>>
> You might want to read the code more carefully. The drivers are 
> instantiated
> from drivers/hwmon/sch56xx-common.c which does add the resource.
Yes, it does, thanks for pointing it out.
>
> Guenter
>
> .

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-04-24  6:21 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22  9:11 [PATCH 00/20] hwmon: check return value after calling platform_get_resource() Yang Yingliang
2022-04-22  9:11 ` [PATCH 01/20] hwmon: (abituguru) " Yang Yingliang
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.