mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug
@ 2024-11-30 10:07 ` Dan Carpenter
  2024-11-30 12:34   ` Markus Elfring
  2024-12-02  9:31   ` Michal Wilczynski
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-11-30 10:07 UTC (permalink / raw)
  To: Michal Wilczynski
  Cc: Drew Fustini, Guo Ren, Fu Wei, Jassi Brar, linux-riscv,
	linux-kernel, kernel-janitors

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug
  2024-11-30 10:07 ` [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug Dan Carpenter
@ 2024-11-30 12:34   ` Markus Elfring
  2024-12-02  9:31   ` Michal Wilczynski
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-11-30 12:34 UTC (permalink / raw)
  To: Dan Carpenter, linux-riscv, Michal Wilczynski
  Cc: kernel-janitors, LKML, Drew Fustini, Fu Wei, Guo Ren, Jassi Brar

> The devm_ioremap() function doesn't return error pointers, it returns
> NULL.  Update the error checking to match.

  on execution failure?


Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug
  2024-11-30 10:07 ` [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug Dan Carpenter
  2024-11-30 12:34   ` Markus Elfring
@ 2024-12-02  9:31   ` Michal Wilczynski
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Wilczynski @ 2024-12-02  9:31 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Drew Fustini, Guo Ren, Fu Wei, Jassi Brar, linux-riscv,
	linux-kernel, kernel-janitors



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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-02  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20241130100751eucas1p25283ed89679b086be2863092149236b8@eucas1p2.samsung.com>
2024-11-30 10:07 ` [PATCH] mailbox: th1520: Fix a NULL vs IS_ERR() bug Dan Carpenter
2024-11-30 12:34   ` Markus Elfring
2024-12-02  9:31   ` Michal Wilczynski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®