From: Martin Habets <habetsm.xilinx@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Edward Cree <ecree.xilinx@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jonathan Cooper <jonathan.s.cooper@amd.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH] sfc: Fix an error handling path in efx_pci_probe()
Date: Mon, 31 Oct 2022 09:09:35 +0000 [thread overview]
Message-ID: <Y1+Qz9z+qy/kkW9B@gmail.com> (raw)
In-Reply-To: <dc114193121c52c8fa3779e49bdd99d4b41344a9.1667077009.git.christophe.jaillet@wanadoo.fr>
Please specify a branch in the subject.
This patch should go to net.
On Sat, Oct 29, 2022 at 10:57:11PM +0200, Christophe JAILLET wrote:
> If an error occurs after the first kzalloc() the corresponding memory
> allocation is never freed.
>
> Add the missing kfree() in the error handling path, as already done in the
> remove() function.
>
> Fixes: 7e773594dada ("sfc: Separate efx_nic memory from net_device memory")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Martin Habets <habetsm.xilinx@gmail.com>
> ---
> When 7e773594dada was merged, sfc/ef100.c had the same issue.
> But it seems to have been fixed in 98ff4c7c8ac7.
I agree.
> ---
> drivers/net/ethernet/sfc/efx.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
> index 054d5ce6029e..0556542d7a6b 100644
> --- a/drivers/net/ethernet/sfc/efx.c
> +++ b/drivers/net/ethernet/sfc/efx.c
> @@ -1059,8 +1059,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
>
> /* Allocate and initialise a struct net_device */
> net_dev = alloc_etherdev_mq(sizeof(probe_data), EFX_MAX_CORE_TX_QUEUES);
> - if (!net_dev)
> - return -ENOMEM;
> + if (!net_dev) {
> + rc = -ENOMEM;
> + goto fail0;
> + }
> probe_ptr = netdev_priv(net_dev);
> *probe_ptr = probe_data;
> efx->net_dev = net_dev;
> @@ -1132,6 +1134,8 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
> WARN_ON(rc > 0);
> netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc);
> free_netdev(net_dev);
> + fail0:
> + kfree(probe_data);
> return rc;
> }
>
> --
> 2.34.1
next prev parent reply other threads:[~2022-10-31 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-29 20:57 [PATCH] sfc: Fix an error handling path in efx_pci_probe() Christophe JAILLET
2022-10-31 9:09 ` Martin Habets [this message]
2022-11-01 16:30 ` patchwork-bot+netdevbpf
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=Y1+Qz9z+qy/kkW9B@gmail.com \
--to=habetsm.xilinx@gmail.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=jonathan.s.cooper@amd.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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