kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] ethernet: fix potential memory leak in gemini_ethernet_port_probe()
@ 2020-07-29  8:38 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2020-07-29  8:38 UTC (permalink / raw)
  To: Lu Wei, linux-arm-kernel, netdev
  Cc: linux-kernel, kernel-janitors, David S. Miller, Hans Ulli Kroll,
	Jakub Kicinski, Linus Walleij, Michał Mirosław

> If some processes in gemini_ethernet_port_probe() fail,
> free_netdev(dev) needs to be called to avoid a memory leak.

Would you like to use an imperative wording for this change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=6ba1b005ffc388c2aeaddae20da29e4810dea298#n151> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -2501,8 +2513,10 @@  static int gemini_ethernet_port_probe(struct platform_device *pdev)
>  					IRQF_SHARED,
>  					port_names[port->id],
>  					port);
> -	if (ret)
> +	if (ret) {
> +		free_netdev(netdev);
>  		return ret;
> +	}
>
>  	ret = register_netdev(netdev);
…

I suggest to add a jump target for the desired exception handling
in this function implementation.

 	if (ret)
-		return ret;
+		goto free_netdev;

Regards,
Markus

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-29  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29  8:38 [PATCH] ethernet: fix potential memory leak in gemini_ethernet_port_probe() Markus Elfring

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