linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: renesas-rpc-if: fix possible NULL pointer dereference of resource
@ 2021-04-07 15:43 Krzysztof Kozlowski
  2021-04-13 14:58 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-07 15:43 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lad Prabhakar, Sergei Shtylyov, linux-kernel

The platform_get_resource_byname() can return NULL which would be
immediately dereferenced by resource_size().  Instead dereference it
after validating the resource.

Addresses-Coverity: Dereference null return value
Fixes: ca7d8b980b67 ("memory: add Renesas RPC-IF driver")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/memory/renesas-rpc-if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c
index 8d36e221def1..45eed659b0c6 100644
--- a/drivers/memory/renesas-rpc-if.c
+++ b/drivers/memory/renesas-rpc-if.c
@@ -192,10 +192,10 @@ int rpcif_sw_init(struct rpcif *rpc, struct device *dev)
 	}
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap");
-	rpc->size = resource_size(res);
 	rpc->dirmap = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(rpc->dirmap))
 		rpc->dirmap = NULL;
+	rpc->size = resource_size(res);
 
 	rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
 
-- 
2.25.1


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

* Re: [PATCH] memory: renesas-rpc-if: fix possible NULL pointer dereference of resource
  2021-04-07 15:43 [PATCH] memory: renesas-rpc-if: fix possible NULL pointer dereference of resource Krzysztof Kozlowski
@ 2021-04-13 14:58 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-13 14:58 UTC (permalink / raw)
  To: Lad Prabhakar, Sergei Shtylyov, linux-kernel, Krzysztof Kozlowski

On Wed, 7 Apr 2021 17:43:57 +0200, Krzysztof Kozlowski wrote:
> The platform_get_resource_byname() can return NULL which would be
> immediately dereferenced by resource_size().  Instead dereference it
> after validating the resource.

Applied, thanks!

[1/1] memory: renesas-rpc-if: fix possible NULL pointer dereference of resource
      commit: 59e27d7c94aa02da039b000d33c304c179395801

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

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

end of thread, other threads:[~2021-04-13 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 15:43 [PATCH] memory: renesas-rpc-if: fix possible NULL pointer dereference of resource Krzysztof Kozlowski
2021-04-13 14:58 ` 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).