From: Simon Horman <horms@kernel.org>
To: zilin@seu.edu.cn
Cc: davem@davemloft.net, andrew+netdev@lunn.ch,
jianhao.xu@seu.edu.cn, kuba@kernel.org,
kory.maincent@bootlin.com, marco.crivellari@suse.com,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
vadim.fedorenko@linux.dev, edumazet@google.com,
pabeni@redhat.com
Subject: Re: [net,v2,1/2] net: liquidio: Fix off-by-one error in setup_nic_devices() cleanup
Date: Mon, 26 Jan 2026 15:56:07 +0000 [thread overview]
Message-ID: <aXeOl5D7BR-xnEgm@horms.kernel.org> (raw)
In-Reply-To: <20260126155039.1391193-1-horms@kernel.org>
On Mon, Jan 26, 2026 at 03:50:39PM +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: Fix off-by-one error in setup_nic_devices() cleanup
>
> This patch changes the cleanup loop from while(i--) to do{}while(i--)
> to ensure that when a device fails to initialize, it gets cleaned up
> along with all previously initialized devices.
>
> > diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> > index 0732440eeacd..3ba2806f5d1e 100644
> > --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
> > +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
> > @@ -3765,11 +3765,11 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
> >
> > setup_nic_dev_free:
> >
> > - while (i--) {
> > + do {
> > dev_err(&octeon_dev->pci_dev->dev,
> > "NIC ifidx:%d Setup failed\n", i);
> > liquidio_destroy_nic_device(octeon_dev, i);
> > - }
> > + } while (i--);
>
> In lio_main.c, setup_nic_devices() can also reach setup_nic_dev_free from
> the devlink_alloc() failure path after the main for loop completes. At that
> point i equals ifcount (the loop counter has been incremented past the last
> valid device).
>
> With the do-while change, the first iteration will call
> liquidio_destroy_nic_device(octeon_dev, ifcount) for a device index that
> was never initialized. The function has a guard for NULL netdev so it will
> not crash, but it will print a spurious error message about a device that
> never existed.
>
> The fix works correctly for failures within the loop (which is the case
> described in the commit message), but is there a way to handle the
> post-loop devlink_alloc() failure case without printing the spurious
> error message?
Sorry for not realising this when I made this suggestion in
my review of v1.
Also, I would suggest splitting this patch in two: one patch
per driver.
next prev parent reply other threads:[~2026-01-26 15:56 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 [this message]
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
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=aXeOl5D7BR-xnEgm@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