[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20260124124205.102499-2-zilin@seu.edu.cn>
Date: Sat, 24 Jan 2026 12:42:04 +0000
From: Zilin Guan <zilin@....edu.cn>
To: andrew+netdev@...n.ch
Cc: davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
marco.crivellari@...e.com,
vadim.fedorenko@...ux.dev,
kory.maincent@...tlin.com,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
horms@...nel.org,
jianhao.xu@....edu.cn,
Zilin Guan <zilin@....edu.cn>
Subject: [PATCH net v2 1/2] net: liquidio: Fix off-by-one error in setup_nic_devices() cleanup
In setup_nic_devices, the initialization loop jumps to the label
setup_nic_dev_free on failure. The current error handling path uses
a while loop that decrements the device index i. This logic skips
the release of resources for the device at the current index i where
the failure occurred.
Use a do-while loop instead. This guarantees that
liquidio_destroy_nic_device() is called for the failing device index i
and continues for all previously initialized devices.
Compile tested only. Issue found using code review.
Fixes: f21fb3ed364b ("Add support of Cavium Liquidio ethernet adapters")
Fixes: 846b46873eeb ("liquidio CN23XX: VF offload features")
Suggested-by: Simon Horman <horms@...nel.org>
Signed-off-by: Zilin Guan <zilin@....edu.cn>
---
drivers/net/ethernet/cavium/liquidio/lio_main.c | 4 ++--
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
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:
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index e02942dbbcce..43c595f3b84e 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -2212,11 +2212,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:
--
2.34.1
Powered by blists - more mailing lists