diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-04-07 17:43:57 +0200 |
---|---|---|
committer | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-04-13 16:55:02 +0200 |
commit | 59e27d7c94aa02da039b000d33c304c179395801 (patch) | |
tree | ba7c489b4009fcdafdd64324d0ea4425b24792bb /drivers/memory | |
parent | 25dcca7fedcd4e31cb368ad846bfd738c0c6307c (diff) | |
download | linux-59e27d7c94aa02da039b000d33c304c179395801.tar.gz linux-59e27d7c94aa02da039b000d33c304c179395801.tar.bz2 linux-59e27d7c94aa02da039b000d33c304c179395801.zip |
memory: renesas-rpc-if: fix possible NULL pointer dereference of resource
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>
Link: https://lore.kernel.org/r/20210407154357.70200-1-krzysztof.kozlowski@canonical.com
Diffstat (limited to 'drivers/memory')
-rw-r--r-- | drivers/memory/renesas-rpc-if.c | 2 |
1 files changed, 1 insertions, 1 deletions
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); |