Skip to content

Commit

Permalink
net: smc91x: Fix possible memory leak in smc_drv_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit bca9749 ]

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: 7d2911c ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Wang Hai authored and gregkh committed Jul 27, 2020
1 parent 4e0bc47 commit cefee97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/smsc/smc91x.c
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,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
Expand All @@ -2296,7 +2296,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
Expand Down

0 comments on commit cefee97

Please sign in to comment.