From: Kory Maincent <kory.maincent@bootlin.com>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: horms@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@google.com, jianhao.xu@seu.edu.cn, kuba@kernel.org,
linux-kernel@vger.kernel.org, marco.crivellari@suse.com,
netdev@vger.kernel.org, pabeni@redhat.com,
vadim.fedorenko@linux.dev
Subject: Re: [PATCH net v3 3/3] net: liquidio: Initialize netdev pointer before queue setup
Date: Tue, 27 Jan 2026 18:04:01 +0100 [thread overview]
Message-ID: <20260127180401.69787770@kmaincent-XPS-13-7390> (raw)
In-Reply-To: <20260127151241.1144039-4-zilin@seu.edu.cn>
On Tue, 27 Jan 2026 15:12:41 +0000
Zilin Guan <zilin@seu.edu.cn> wrote:
> In setup_nic_devices(), the netdev is allocated using alloc_etherdev_mq().
> However, the pointer to this structure is stored in oct->props[i].netdev
> only after the calls to netif_set_real_num_rx_queues() and
> netif_set_real_num_tx_queues().
>
> If either of these functions fails, setup_nic_devices() returns an error
> without freeing the allocated netdev. Since oct->props[i].netdev is still
> NULL at this point, the cleanup function liquidio_destroy_nic_device()
> will fail to find and free the netdev, resulting in a memory leak.
>
> Fix this by initializing oct->props[i].netdev before calling the queue
> setup functions. This ensures that the netdev is properly accessible for
> cleanup in case of errors.
>
> Compile tested only. Issue found using a prototype static analysis tool
> and code review.
I think this patch should be moved before patch 1.
Thanks to Patch 1 we are now cleaning the failing index, but we could face
dereference NULL pointer if we are failing in one of those
netif_set_real_num_rx_queues() and netif_set_real_num_tx_queues() functions.
With this patch moved:
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Thank you!
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-01-27 17:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 15:12 [PATCH net v3 0/3] net: liquidio: Fix memory leaks in setup_nic_devices() Zilin Guan
2026-01-27 15:12 ` [PATCH net v3 1/3] net: liquidio: Fix off-by-one error in PF setup_nic_devices() cleanup Zilin Guan
2026-01-27 16:51 ` Kory Maincent
2026-01-27 15:12 ` [PATCH net v3 2/3] net: liquidio: Fix off-by-one error in VF " Zilin Guan
2026-01-27 16:54 ` Kory Maincent
2026-01-27 15:12 ` [PATCH net v3 3/3] net: liquidio: Initialize netdev pointer before queue setup Zilin Guan
2026-01-27 17:04 ` Kory Maincent [this message]
2026-01-27 21:05 ` [PATCH net v3 0/3] net: liquidio: Fix memory leaks in setup_nic_devices() Jakub Kicinski
2026-01-28 4:20 ` Zilin Guan
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=20260127180401.69787770@kmaincent-XPS-13-7390 \
--to=kory.maincent@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jianhao.xu@seu.edu.cn \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.crivellari@suse.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
--cc=zilin@seu.edu.cn \
/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
all inboxes | Powered by JetHome®