Skip to contentSkip to conversation

fsi: fsi-occ: fix return value check in occ_probe()

PATCH In review Xu Wang 3 participants 3 messages Jul 13, 2020 – Jul 20, 2020 FSI

lore
Share & tools
lore

Xu Wang

author
#0 lore raw

PATCH 1/1 fsi: fsi-occ: fix return value check in occ_probe()

In case of error, the function platform_device_register_full() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

---
 drivers/fsi/fsi-occ.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fsi/fsi-occ.c +1 -1
index 7da9c81759ac..9eeb856c8905 100644
@@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)
 
 	hwmon_dev_info.id = occ->idx;
 	hwmon_dev = platform_device_register_full(&hwmon_dev_info);
-	if (!hwmon_dev)
+	if (IS_ERR(hwmon_dev))
 		dev_warn(dev, "failed to create hwmon device\n");
 
 	return 0;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Xu Wang

In case of error, the function platform_device_register_full() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Thanks,

Quoted 19 lines
---
  drivers/fsi/fsi-occ.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fsi/fsi-occ.c +1 -1
index 7da9c81759ac..9eeb856c8905 100644
@@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)
 
  	hwmon_dev_info.id = occ->idx;
  	hwmon_dev = platform_device_register_full(&hwmon_dev_info);
-	if (!hwmon_dev)
+	if (IS_ERR(hwmon_dev))
  		dev_warn(dev, "failed to create hwmon device\n");
 
  	return 0;
Reviewed-by on v1 1/1
#2 lore raw
In reply to Xu Wang
Quoted 5 lines · Xu Wang

In case of error, the function platform_device_register_full() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Quoted 18 lines
---
 drivers/fsi/fsi-occ.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fsi/fsi-occ.c +1 -1
index 7da9c81759ac..9eeb856c8905 100644
@@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)
 
 	hwmon_dev_info.id = occ->idx;
 	hwmon_dev = platform_device_register_full(&hwmon_dev_info);
-	if (!hwmon_dev)
+	if (IS_ERR(hwmon_dev))
 		dev_warn(dev, "failed to create hwmon device\n");
 
 	return 0;