stmmac: dwmac-mediatek: fix resource leak in probe
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 28 Jul 2022 11:52:09 +0000 (14:52 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 28 Jul 2022 17:43:04 +0000 (10:43 -0700)
If mediatek_dwmac_clks_config() fails, then call stmmac_remove_config_dt()
before returning.  Otherwise it is a resource leak.

Fixes: fa4b3ca60e80 ("stmmac: dwmac-mediatek: fix clock issue")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YuJ4aZyMUlG6yGGa@kili
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c

index ca8ab290013ce3fd79b9251fedc8f9a59b8d8381..d42e1afb65213419ada4168f1c227a1d7c815c23 100644 (file)
@@ -688,18 +688,19 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)
 
        ret = mediatek_dwmac_clks_config(priv_plat, true);
        if (ret)
-               return ret;
+               goto err_remove_config_dt;
 
        ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
-       if (ret) {
-               stmmac_remove_config_dt(pdev, plat_dat);
+       if (ret)
                goto err_drv_probe;
-       }
 
        return 0;
 
 err_drv_probe:
        mediatek_dwmac_clks_config(priv_plat, false);
+err_remove_config_dt:
+       stmmac_remove_config_dt(pdev, plat_dat);
+
        return ret;
 }