[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20260124072057.3914059-1-zilin@seu.edu.cn>
Date: Sat, 24 Jan 2026 07:20:57 +0000
From: Zilin Guan <zilin@....edu.cn>
To: horms@...nel.org
Cc: andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
jianhao.xu@....edu.cn,
kuba@...nel.org,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org,
pabeni@...hat.com,
zilin@....edu.cn
Subject: Re: [PATCH net] net: liquidio: Fix memory leak in setup_nic_devices()
On Fri, Jan 23, 2026 at 05:21:11PM +0000, Simon Horman wrote:
> Thanks Zilin,
>
> I agree with your analysis, and proposed fix.
> And that the problem appears to have been introduced in the cited commit.
>
> But I am wondering if we also need the following, probably as a separate
> commit, to ensure that liquidio_destroy_nic_device is called for the
> element of props[i] whose assingment your patch addresses.
>
> Also compile tested only.
>
> 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--);
>
> setup_nic_dev_done:
>
> ...
Hi Simon,
Thanks for the review and the suggestion.
I agree with you. The current while (i--) loop indeed skips the cleanup
for the device index i that actually failed. I also noticed that
lio_vf_main.c shares the exact same issues.
I'll send a v2 series to correct both files, and I'll include the loop fix
as a separate commit as you suggested.
Best regards,
Zilin
Powered by blists - more mailing lists