[PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug

Dan Carpenter posted 1 patch 1 year, 2 months ago
drivers/mailbox/mailbox-th1520.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug
Posted by Dan Carpenter 1 year, 2 months ago
The devm_ioremap() function doesn't return error pointers, it returns
NULL.  Update the error checking to match.

Fixes: 5d4d263e1c6b ("mailbox: Introduce support for T-head TH1520 Mailbox driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/mailbox/mailbox-th1520.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mailbox/mailbox-th1520.c b/drivers/mailbox/mailbox-th1520.c
index 4e84640ac3b8..e16e7c85ee3c 100644
--- a/drivers/mailbox/mailbox-th1520.c
+++ b/drivers/mailbox/mailbox-th1520.c
@@ -387,8 +387,10 @@ static void __iomem *th1520_map_mmio(struct platform_device *pdev,
 
 	mapped = devm_ioremap(&pdev->dev, res->start + offset,
 			      resource_size(res) - offset);
-	if (IS_ERR(mapped))
+	if (!mapped) {
 		dev_err(&pdev->dev, "Failed to map resource: %s\n", res_name);
+		return ERR_PTR(-ENOMEM);
+	}
 
 	return mapped;
 }
-- 
2.45.2
Re: [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug
Posted by Michal Wilczynski 1 year, 2 months ago

On 11/30/24 11:07, Dan Carpenter wrote:
> The devm_ioremap() function doesn't return error pointers, it returns
> NULL.  Update the error checking to match.
> 
> Fixes: 5d4d263e1c6b ("mailbox: Introduce support for T-head TH1520 Mailbox driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/mailbox/mailbox-th1520.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mailbox/mailbox-th1520.c b/drivers/mailbox/mailbox-th1520.c
> index 4e84640ac3b8..e16e7c85ee3c 100644
> --- a/drivers/mailbox/mailbox-th1520.c
> +++ b/drivers/mailbox/mailbox-th1520.c
> @@ -387,8 +387,10 @@ static void __iomem *th1520_map_mmio(struct platform_device *pdev,
>  
>  	mapped = devm_ioremap(&pdev->dev, res->start + offset,
>  			      resource_size(res) - offset);
> -	if (IS_ERR(mapped))
> +	if (!mapped) {
>  		dev_err(&pdev->dev, "Failed to map resource: %s\n", res_name);
> +		return ERR_PTR(-ENOMEM);
> +	}
>  
>  	return mapped;
>  }


Looks good, thanks !
Reviewed-by: Michal Wilczynski <m.wilczynski@samsung.com>
Re: [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug
Posted by Markus Elfring 1 year, 2 months ago
> The devm_ioremap() function doesn't return error pointers, it returns
> NULL.  Update the error checking to match.

  on execution failure?


Regards,
Markus