Skip to contentSkip to conversation

hwmon: fix a NULL vs IS_ERR() check in xgene_hwmon_probe()

PATCH Superseded [email protected] 2 participants 2 messages Mar 2, 2025 Hardware monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: fix a NULL vs IS_ERR() check in xgene_hwmon_probe()

From: Xinghuo Chen <[email protected]>

The devm_memremap() function returns error pointers on error, it doesn't return NULL.

---
 drivers/hwmon/xgene-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/xgene-hwmon.c +1 -1
index 1e3bd129a922..4fe30198bae8 100644
@@ -706,7 +706,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 			goto out;
 		}
 
-		if (!ctx->pcc_comm_addr) {
+		if (IS_ERR(ctx->pcc_comm_addr)) {
 			dev_err(&pdev->dev,
 				"Failed to ioremap PCC comm region\n");
 			rc = -ENOMEM;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 6 lines · On 3/1/25 19:43, [email protected] wrote:

From: Xinghuo Chen <[email protected]>

The devm_memremap() function returns error pointers on error, it doesn't return NULL.

Fixes c7cefce03e69 ("hwmon: (xgene) access mailbox as RAM")
Quoted 9 lines
---
  drivers/hwmon/xgene-hwmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/xgene-hwmon.c +0 -0
index 1e3bd129a922..4fe30198bae8 100644

drivers/hwmon/xgene-hwmon.c static int xgene_hwmon_probe(struct platform_device *pdev) · line 712

Quoted 8 lines
drivers/hwmon/xgene-hwmon.c +1 -1
@@ -706,7 +706,7 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
  			goto out;
  		}
 
-		if (!ctx->pcc_comm_addr) {
+		if (IS_ERR(ctx->pcc_comm_addr)) {
  			dev_err(&pdev->dev,
  				"Failed to ioremap PCC comm region\n");
  			rc = -ENOMEM;

While it is correct that devm_memremap() returns an ERR_PTR() on error, devm_ioremap() returns NULL. So this has to be IS_ERR_OR_NULL().

Guenter