linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
@ 2020-12-12 18:20 Christophe JAILLET
  2020-12-12 23:05 ` Florian Fainelli
  2020-12-16 19:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2020-12-12 18:20 UTC (permalink / raw)
  To: opendmb, f.fainelli, davem, kuba
  Cc: bcm-kernel-feedback-list, netdev, linux-kernel, kernel-janitors,
	Christophe JAILLET

If the 'register_netdev()' call fails, we must undo a previous
'bcmgenet_mii_init()' call.

Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
The missing 'bcmgenet_mii_exit()' call is added here, instead of in the
error handling path in order to avoid some goto spaghetti code.
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index be85dad2e3bc..fcca023f22e5 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -4069,8 +4069,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk);
 
 	err = register_netdev(dev);
-	if (err)
+	if (err) {
+		bcmgenet_mii_exit(dev);
 		goto err;
+	}
 
 	return err;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
  2020-12-12 18:20 [PATCH] net: bcmgenet: Fix a resource leak in an error handling path in the probe functin Christophe JAILLET
@ 2020-12-12 23:05 ` Florian Fainelli
  2020-12-16 19:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2020-12-12 23:05 UTC (permalink / raw)
  To: Christophe JAILLET, opendmb, davem, kuba
  Cc: bcm-kernel-feedback-list, netdev, linux-kernel, kernel-janitors



On 12/12/2020 10:20 AM, Christophe JAILLET wrote:
> If the 'register_netdev()' call fails, we must undo a previous
> 'bcmgenet_mii_init()' call.
> 
> Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>

> ---
> The missing 'bcmgenet_mii_exit()' call is added here, instead of in the
> error handling path in order to avoid some goto spaghetti code.

Yes that makes sense, thanks!
-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
  2020-12-12 18:20 [PATCH] net: bcmgenet: Fix a resource leak in an error handling path in the probe functin Christophe JAILLET
  2020-12-12 23:05 ` Florian Fainelli
@ 2020-12-16 19:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-12-16 19:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: opendmb, f.fainelli, davem, kuba, bcm-kernel-feedback-list,
	netdev, linux-kernel, kernel-janitors

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Sat, 12 Dec 2020 19:20:05 +0100 you wrote:
> If the 'register_netdev()' call fails, we must undo a previous
> 'bcmgenet_mii_init()' call.
> 
> Fixes: 1c1008c793fa ("net: bcmgenet: add main driver file")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> The missing 'bcmgenet_mii_exit()' call is added here, instead of in the
> error handling path in order to avoid some goto spaghetti code.
> 
> [...]

Here is the summary with links:
  - net: bcmgenet: Fix a resource leak in an error handling path in the probe functin
    https://git.kernel.org/netdev/net/c/4375ada01963

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-16 19:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12 18:20 [PATCH] net: bcmgenet: Fix a resource leak in an error handling path in the probe functin Christophe JAILLET
2020-12-12 23:05 ` Florian Fainelli
2020-12-16 19:10 ` patchwork-bot+netdevbpf

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).