diff mbox series

[v2] hwmon: fix a NULL vs IS_ERR_OR_NULL() check in xgene_hwmon_probe()

Message ID tencent_9AD8E7683EC29CAC97496B44F3F865BA070A@qq.com (mailing list archive)
State Accepted
Headers show
Series [v2] hwmon: fix a NULL vs IS_ERR_OR_NULL() check in xgene_hwmon_probe() | expand

Commit Message

xinghuo.chen@foxmail.com March 3, 2025, 12:57 p.m. UTC
From: Xinghuo Chen <xinghuo.chen@foxmail.com>

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

Fixes: c7cefce03e69 ("hwmon: (xgene) access mailbox as RAM")
Signed-off-by: Xinghuo Chen <xinghuo.chen@foxmail.com>
---
v1 -> v2:
Use IS_ERR_OR_NULL() instead of IS_ERR() as devm_ioremap()
return NULL on error.

Link to v1: https://lore.kernel.org/all/tencent_370DBB5BD8EF699EC030ACA74BCB440FFA0A@qq.com
---
 drivers/hwmon/xgene-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Guenter Roeck March 3, 2025, 2:04 p.m. UTC | #1
On Mon, Mar 03, 2025 at 07:57:33AM -0500, 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.
> 
> Fixes: c7cefce03e69 ("hwmon: (xgene) access mailbox as RAM")
> Signed-off-by: Xinghuo Chen <xinghuo.chen@foxmail.com>

Applied.

Thanks,
Guenter

> ---
> v1 -> v2:
> Use IS_ERR_OR_NULL() instead of IS_ERR() as devm_ioremap()
> return NULL on error.
> 
> Link to v1: https://lore.kernel.org/all/tencent_370DBB5BD8EF699EC030ACA74BCB440FFA0A@qq.com
> ---
>  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..7087197383c9 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_OR_NULL(ctx->pcc_comm_addr)) {
>  			dev_err(&pdev->dev,
>  				"Failed to ioremap PCC comm region\n");
>  			rc = -ENOMEM;
diff mbox series

Patch

diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
index 1e3bd129a922..7087197383c9 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_OR_NULL(ctx->pcc_comm_addr)) {
 			dev_err(&pdev->dev,
 				"Failed to ioremap PCC comm region\n");
 			rc = -ENOMEM;