* [PATCH] net: smc91x: Fix possible memory leak in smc_drv_probe()
@ 2020-07-16 3:50 Wang Hai
2020-07-16 6:20 ` Markus Elfring
2020-07-17 19:45 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Wang Hai @ 2020-07-16 3:50 UTC (permalink / raw)
To: nico, davem, kuba, mst, hkallweit1, snelson, elfring, dmitry.torokhov
Cc: netdev, linux-kernel, wanghai26
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>
---
drivers/net/ethernet/smsc/smc91x.c | 4 ++--
1 file 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
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: smc91x: Fix possible memory leak in smc_drv_probe()
2020-07-16 3:50 [PATCH] net: smc91x: Fix possible memory leak in smc_drv_probe() Wang Hai
@ 2020-07-16 6:20 ` Markus Elfring
2020-07-17 19:45 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-07-16 6:20 UTC (permalink / raw)
To: Wang Hai, netdev
Cc: linux-kernel, Wang Hai, Shannon Nelson, Nicolas Pitre,
Michael S. Tsirkin, Jakub Kicinski, Heiner Kallweit,
Dmitry Torokhov, David S. Miller
> 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.
* 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: smc91x: Fix possible memory leak in smc_drv_probe()
2020-07-16 3:50 [PATCH] net: smc91x: Fix possible memory leak in smc_drv_probe() Wang Hai
2020-07-16 6:20 ` Markus Elfring
@ 2020-07-17 19:45 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-07-17 19:45 UTC (permalink / raw)
To: wanghai38
Cc: nico, kuba, mst, hkallweit1, snelson, elfring, dmitry.torokhov,
netdev, linux-kernel, wanghai26
From: Wang Hai <wanghai38@huawei.com>
Date: Thu, 16 Jul 2020 11:50:38 +0800
> 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>
Applied, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-17 19:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 3:50 [PATCH] net: smc91x: Fix possible memory leak in smc_drv_probe() Wang Hai
2020-07-16 6:20 ` Markus Elfring
2020-07-17 19:45 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).