From: Simon Horman <horms@kernel.org>
To: zilin@seu.edu.cn
Cc: vadim.fedorenko@linux.dev, netdev@vger.kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net,
kory.maincent@bootlin.com, edumazet@google.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn,
pabeni@redhat.com, marco.crivellari@suse.com
Subject: Re: [net,v2,2/2] net: liquidio: Initialize netdev pointer before queue setup
Date: Mon, 26 Jan 2026 15:52:52 +0000 [thread overview]
Message-ID: <aXeN1EsGgr_YQi8s@horms.kernel.org> (raw)
In-Reply-To: <20260126154941.1391119-1-horms@kernel.org>
On Mon, Jan 26, 2026 at 03:49:41PM +0000, Simon Horman wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
>
> For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> ---
> net: liquidio: Initialize netdev pointer before queue setup
>
> This patch moves the initialization of lio and props structures earlier
> in setup_nic_devices() so that props->netdev is set before calling
> netif_set_real_num_rx_queues() and netif_set_real_num_tx_queues(). The
> intent is to fix a memory leak where the allocated netdev would not be
> freed if queue setup fails.
>
> > diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> > index 3ba2806f5d1e..2383f0173a54 100644
> > --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
> > +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> > @@ -3505,6 +3505,16 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
> > */
> > netdev->netdev_ops = &lionetdevops;
> >
> > + lio = GET_LIO(netdev);
> > +
> > + memset(lio, 0, sizeof(struct lio));
> > +
> > + lio->ifidx = ifidx_or_pfnum;
> > +
> > + props = &octeon_dev->props[i];
> > + props->gmxport = resp->cfg_info.linfo.gmxport;
> > + props->netdev = netdev;
>
> Moving this initialization earlier fixes the memory leak, but now if
> netif_set_real_num_rx_queues() or netif_set_real_num_tx_queues() fails
> below, the cleanup path in liquidio_destroy_nic_device() will proceed
> further than before since props->netdev is no longer NULL.
>
> Previously, when queue setup failed, liquidio_destroy_nic_device() would
> return early at the "if (!netdev)" check. Now it continues and calls
> cleanup_rx_oom_poll_fn().
>
> In cleanup_rx_oom_poll_fn() (lio_core.c), the code does:
>
> struct lio *lio = GET_LIO(netdev);
> struct octeon_device *oct = lio->oct_dev;
> ...
> for (q_no = 0; q_no < oct->num_oqs; q_no++) {
>
> Since lio->oct_dev is not assigned until much later in setup_nic_devices()
> (around line 3602), it will be NULL after the memset above. Would this
> cause a NULL pointer dereference when cleanup_rx_oom_poll_fn() tries to
> access oct->num_oqs?
>
> > +
> > retval = netif_set_real_num_rx_queues(netdev, num_oqueues);
> > if (retval) {
> > dev_err(&octeon_dev->pci_dev->dev,
>
> [ ... ]
Strangely the AI review did not pick this up for v1.
(And neither did I.)
next prev parent reply other threads:[~2026-01-26 15:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-24 12:42 [PATCH net v2 0/2] net: liquidio: Fix memory leaks in setup_nic_devices() Zilin Guan
2026-01-24 12:42 ` [PATCH net v2 1/2] net: liquidio: Fix off-by-one error in setup_nic_devices() cleanup Zilin Guan
2026-01-26 15:50 ` [net,v2,1/2] " Simon Horman
2026-01-26 15:56 ` Simon Horman
2026-01-27 10:06 ` Zilin Guan
2026-01-24 12:42 ` [PATCH net v2 2/2] net: liquidio: Initialize netdev pointer before queue setup Zilin Guan
2026-01-26 15:49 ` [net,v2,2/2] " Simon Horman
2026-01-26 15:52 ` Simon Horman [this message]
2026-01-27 10:11 ` 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=aXeN1EsGgr_YQi8s@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=kory.maincent@bootlin.com \
--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