From: Markus Elfring <Markus.Elfring@web.de>
To: Lu Wei <luwei32@huawei.com>,
linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
"Hans Ulli Kroll" <ulli.kroll@googlemail.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Subject: Re: [PATCH] ethernet: fix potential memory leak in gemini_ethernet_port_probe()
Date: Wed, 29 Jul 2020 10:38:37 +0200 [thread overview]
Message-ID: <c9c7e5a3-4909-e0c9-1c69-0ad3643ca3f5@web.de> (raw)
> 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
reply other threads:[~2020-07-29 8:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9c7e5a3-4909-e0c9-1c69-0ad3643ca3f5@web.de \
--to=markus.elfring@web.de \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luwei32@huawei.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=ulli.kroll@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).