Commit 69c777a8 authored by Wang Hai's avatar Wang Hai Committed by Khalid Elmously

net: smc91x: Fix possible memory leak in smc_drv_probe()

BugLink: https://bugs.launchpad.net/bugs/1889928

[ Upstream commit bca9749b ]

If try_toggle_control_gpio() failed in smc_drv_probe(), free_netdev(ndev)
should be called to free the ndev created earlier. Otherwise, a memleak
will occur.

Fixes: 7d2911c4 ("net: smc91x: Fix gpios for device tree based booting")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent a971471f
...@@ -2289,7 +2289,7 @@ static int smc_drv_probe(struct platform_device *pdev) ...@@ -2289,7 +2289,7 @@ static int smc_drv_probe(struct platform_device *pdev)
ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio, ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio,
"power", 0, 0, 100); "power", 0, 0, 100);
if (ret) if (ret)
return ret; goto out_free_netdev;
/* /*
* Optional reset GPIO configured? Minimum 100 ns reset needed * Optional reset GPIO configured? Minimum 100 ns reset needed
...@@ -2298,7 +2298,7 @@ static int smc_drv_probe(struct platform_device *pdev) ...@@ -2298,7 +2298,7 @@ static int smc_drv_probe(struct platform_device *pdev)
ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio, ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio,
"reset", 0, 0, 100); "reset", 0, 0, 100);
if (ret) if (ret)
return ret; goto out_free_netdev;
/* /*
* Need to wait for optional EEPROM to load, max 750 us according * Need to wait for optional EEPROM to load, max 750 us according
......
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