diff mbox series

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

Message ID tencent_370DBB5BD8EF699EC030ACA74BCB440FFA0A@qq.com (mailing list archive)
State Changes Requested
Headers show
Series hwmon: fix a NULL vs IS_ERR() check in xgene_hwmon_probe() | expand

Commit Message

xinghuo.chen@foxmail.com March 2, 2025, 3:43 a.m. UTC
From: Xinghuo Chen <xinghuo.chen@foxmail.com>

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

Signed-off-by: Xinghuo Chen <xinghuo.chen@foxmail.com>
---
 drivers/hwmon/xgene-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Guenter Roeck March 2, 2025, 4:25 p.m. UTC | #1
On 3/1/25 19:43, xinghuo.chen@foxmail.com wrote:
> From: Xinghuo Chen <xinghuo.chen@foxmail.com>
> 
> The devm_memremap() function returns error pointers on error,
> it doesn't return NULL.
> 
> Signed-off-by: Xinghuo Chen <xinghuo.chen@foxmail.com>

Fixes: c7cefce03e69 ("hwmon: (xgene) access mailbox as RAM")

> ---
>   drivers/hwmon/xgene-hwmon.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
> index 1e3bd129a922..4fe30198bae8 100644
> --- a/drivers/hwmon/xgene-hwmon.c
> +++ b/drivers/hwmon/xgene-hwmon.c
> @@ -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
diff mbox series

Patch

diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
index 1e3bd129a922..4fe30198bae8 100644
--- a/drivers/hwmon/xgene-hwmon.c
+++ b/drivers/hwmon/xgene-hwmon.c
@@ -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;