net: smc91x: Fix possible memory leak in smc_drv_probe()
Subsystems (3)
PATCH 1/1 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.
--- drivers/net/ethernet/smsc/smc91x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/smsc/smc91x.c +2 -2
@@ -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
Signature · 1 line
2.17.1
Quoted 3 lines
If
try_toggle_control_gpio()failed insmc_drv_probe(),free_netdev(ndev)should be called to free the ndev created earlier. Otherwise, a memleak will occur.
* Will it be nicer to use the term “memory leak” also in this change description?
* Would another imperative wording be preferred for the commit message?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=f8456690ba8eb18ea4714e68554e242a04f65cff#n151
Regards,
Markus
From: Wang Hai <[email protected]>
Date: Thu, 16 Jul 2020 11:50:38 +0800
Quoted 7 lines
If
try_toggle_control_gpio()failed insmc_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 <[email protected]>Signed-off-by Wang Hai <[email protected]>
Applied, thank you.