aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/smsc
diff options
context:
space:
mode:
authorWang Hai <wanghai38@huawei.com>2020-07-16 11:50:38 +0800
committerDavid S. Miller <davem@davemloft.net>2020-07-17 12:44:42 -0700
commitbca9749b1aa23d964d3ab930938af66dbf887f15 (patch)
treee46f2b7ae12dc814ee09caad0ca83cdc1653cc45 /drivers/net/ethernet/smsc
parentrtnetlink: Fix memory(net_device) leak when ->newlink fails (diff)
downloadlinux-dev-bca9749b1aa23d964d3ab930938af66dbf887f15.tar.xz
linux-dev-bca9749b1aa23d964d3ab930938af66dbf887f15.zip
net: smc91x: Fix possible memory leak in smc_drv_probe()
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: 7d2911c43815 ("net: smc91x: Fix gpios for device tree based booting") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Wang Hai <wanghai38@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/smsc')
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 90410f9d3b1a..1c4fea9c3ec4 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2274,7 +2274,7 @@ static int smc_drv_probe(struct platform_device *pdev)
ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio,
"power", 0, 0, 100);
if (ret)
- return ret;
+ goto out_free_netdev;
/*
* Optional reset GPIO configured? Minimum 100 ns reset needed
@@ -2283,7 +2283,7 @@ static int smc_drv_probe(struct platform_device *pdev)
ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio,
"reset", 0, 0, 100);
if (ret)
- return ret;
+ goto out_free_netdev;
/*
* Need to wait for optional EEPROM to load, max 750 us according