Hi!

> From: Zhang Qilong <[email protected]>
> 
> [ Upstream commit 7968c7c79d3be8987feb8021f0c46e6866831408 ]
> 
> In the error handling, we should goto the probe_exit_candev
> to free ndev to prevent memory leak.

Well, that's true.

Unfortunately, 4.19 version has way more exit paths than mainline, so
the fix is not nearly complete. Mainline code is fragile but okay.

> Fixes: dabf54dd1c63 ("can: ti_hecc: Convert TI HECC driver to DT  only 
> driver")

I'm pretty sure problems were there before this commit.

Signed-off-by: Pavel Machek (CIP) <[email protected]>

Best regards,
                                                                Pavel

diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
index 81a3fdd5e010..4400a1a7dbd0 100644
--- a/drivers/net/can/ti_hecc.c
+++ b/drivers/net/can/ti_hecc.c
@@ -897,7 +897,8 @@ static int ti_hecc_probe(struct platform_device *pdev)
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc");
        if (!res) {
                dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc\n");
-               return -EINVAL;
+               err = -EINVAL;
+               goto probe_exit_candev;
        }
 
        priv->base = devm_ioremap_resource(&pdev->dev, res);
@@ -911,7 +912,8 @@ static int ti_hecc_probe(struct platform_device *pdev)
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc-ram");
        if (!res) {
                dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc-ram\n");
-               return -EINVAL;
+               err = -EINVAL;
+               goto probe_exit_candev;
        }
 
        priv->hecc_ram = devm_ioremap_resource(&pdev->dev, res);
@@ -925,7 +927,8 @@ static int ti_hecc_probe(struct platform_device *pdev)
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mbx");
        if (!res) {
                dev_err(&pdev->dev, "can't get IORESOURCE_MEM mbx\n");
-               return -EINVAL;
+               err = -EINVAL;
+               goto probe_exit_candev;
        }
 
        priv->mbx = devm_ioremap_resource(&pdev->dev, res);


-- 
http://www.livejournal.com/~pavelmachek

Attachment: signature.asc
Description: Digital signature

Reply via email to