Commit cbe86768 authored by Hui Tang's avatar Hui Tang Committed by Jakub Kicinski

net: mvpp2: fix possible invalid pointer dereference

It will cause invalid pointer dereference to priv->cm3_base behind,
if PTR_ERR(priv->cm3_base) in mvpp2_get_sram().

Fixes: e54ad1e0 ("net: mvpp2: add CM3 SRAM memory map")
Signed-off-by: default avatarHui Tang <tanghui20@huawei.com>
Link: https://lore.kernel.org/r/20221117084032.101144-1-tanghui20@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 594c61ff
...@@ -7350,6 +7350,7 @@ static int mvpp2_get_sram(struct platform_device *pdev, ...@@ -7350,6 +7350,7 @@ static int mvpp2_get_sram(struct platform_device *pdev,
struct mvpp2 *priv) struct mvpp2 *priv)
{ {
struct resource *res; struct resource *res;
void __iomem *base;
res = platform_get_resource(pdev, IORESOURCE_MEM, 2); res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
if (!res) { if (!res) {
...@@ -7360,9 +7361,12 @@ static int mvpp2_get_sram(struct platform_device *pdev, ...@@ -7360,9 +7361,12 @@ static int mvpp2_get_sram(struct platform_device *pdev,
return 0; return 0;
} }
priv->cm3_base = devm_ioremap_resource(&pdev->dev, res); base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(base))
return PTR_ERR(base);
return PTR_ERR_OR_ZERO(priv->cm3_base); priv->cm3_base = base;
return 0;
} }
static int mvpp2_probe(struct platform_device *pdev) static int mvpp2_probe(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment