kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe()
@ 2020-08-03 14:36 Dan Carpenter
  2020-08-04  6:46 ` Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-08-03 14:36 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Krzysztof Kozlowski, linux-kernel, kernel-janitors

The devm_ioremap() function returns NULL on error, it doesn't return
error pointers.  This bug could lead to an Oops during probe.

Fixes: f046e4a3f0b9 ("memory: jz4780_nemc: Only request IO memory the driver will use")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/memory/jz4780-nemc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c
index 3ec5cb0fce1e..608ae925e641 100644
--- a/drivers/memory/jz4780-nemc.c
+++ b/drivers/memory/jz4780-nemc.c
@@ -304,9 +304,9 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
 	}
 
 	nemc->base = devm_ioremap(dev, res->start, NEMC_REG_LEN);
-	if (IS_ERR(nemc->base)) {
+	if (!nemc->base) {
 		dev_err(dev, "failed to get I/O memory\n");
-		return PTR_ERR(nemc->base);
+		return -ENOMEM;
 	}
 
 	writel(0, nemc->base + NEMC_NFCSR);
-- 
2.27.0

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

* Re: [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe()
  2020-08-03 14:36 [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe() Dan Carpenter
@ 2020-08-04  6:46 ` Krzysztof Kozlowski
  2020-08-05  0:04 ` Paul Cercueil
  2020-08-17 12:06 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-04  6:46 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Paul Cercueil, linux-kernel, kernel-janitors

On Mon, Aug 03, 2020 at 05:36:07PM +0300, Dan Carpenter wrote:
> The devm_ioremap() function returns NULL on error, it doesn't return
> error pointers.  This bug could lead to an Oops during probe.
> 
> Fixes: f046e4a3f0b9 ("memory: jz4780_nemc: Only request IO memory the driver will use")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/memory/jz4780-nemc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thanks, good patch. The pull request with offending patch was merged
into arm-soc so I expect soon will be merged to Linus' tree. Therefore
I'll apply this after merge window to current fixes.

Best regards,
Krzysztof

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

* Re: [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe()
  2020-08-03 14:36 [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe() Dan Carpenter
  2020-08-04  6:46 ` Krzysztof Kozlowski
@ 2020-08-05  0:04 ` Paul Cercueil
  2020-08-17 12:06 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2020-08-05  0:04 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Krzysztof Kozlowski, linux-kernel, kernel-janitors



Le lun. 3 août 2020 à 17:36, Dan Carpenter <dan.carpenter@oracle.com> 
a écrit :
> The devm_ioremap() function returns NULL on error, it doesn't return
> error pointers.  This bug could lead to an Oops during probe.
> 
> Fixes: f046e4a3f0b9 ("memory: jz4780_nemc: Only request IO memory the 
> driver will use")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Paul Cercueil <paul@crapouillou.net>

Thanks!
-Paul

> ---
>  drivers/memory/jz4780-nemc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/memory/jz4780-nemc.c 
> b/drivers/memory/jz4780-nemc.c
> index 3ec5cb0fce1e..608ae925e641 100644
> --- a/drivers/memory/jz4780-nemc.c
> +++ b/drivers/memory/jz4780-nemc.c
> @@ -304,9 +304,9 @@ static int jz4780_nemc_probe(struct 
> platform_device *pdev)
>  	}
> 
>  	nemc->base = devm_ioremap(dev, res->start, NEMC_REG_LEN);
> -	if (IS_ERR(nemc->base)) {
> +	if (!nemc->base) {
>  		dev_err(dev, "failed to get I/O memory\n");
> -		return PTR_ERR(nemc->base);
> +		return -ENOMEM;
>  	}
> 
>  	writel(0, nemc->base + NEMC_NFCSR);
> --
> 2.27.0
> 

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

* Re: [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe()
  2020-08-03 14:36 [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe() Dan Carpenter
  2020-08-04  6:46 ` Krzysztof Kozlowski
  2020-08-05  0:04 ` Paul Cercueil
@ 2020-08-17 12:06 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-17 12:06 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Paul Cercueil, linux-kernel, kernel-janitors

On Mon, Aug 03, 2020 at 05:36:07PM +0300, Dan Carpenter wrote:
> The devm_ioremap() function returns NULL on error, it doesn't return
> error pointers.  This bug could lead to an Oops during probe.
> 
> Fixes: f046e4a3f0b9 ("memory: jz4780_nemc: Only request IO memory the driver will use")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/memory/jz4780-nemc.c | 4 ++--

Thanks, applied.

Best regards,
Krzysztof

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

end of thread, other threads:[~2020-08-17 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03 14:36 [PATCH] memory: jz4780_nemc: Fix an error pointer vs NULL check in probe() Dan Carpenter
2020-08-04  6:46 ` Krzysztof Kozlowski
2020-08-05  0:04 ` Paul Cercueil
2020-08-17 12:06 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).