public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v4 0/3] net: liquidio: Fix memory leaks in setup_nic_devices()
@ 2026-01-28 15:44 Zilin Guan
  2026-01-28 15:44 ` [PATCH net v4 1/3] net: liquidio: Initialize netdev pointer before queue setup Zilin Guan
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Zilin Guan @ 2026-01-28 15:44 UTC (permalink / raw)
  To: andrew+netdev
  Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel,
	kory.maincent, horms, jianhao.xu, marco.crivellari,
	vadim.fedorenko, Zilin Guan

This series fixes memory leaks in the initialization paths of the 
NIC devices.

Patch 1 moves the initialization of oct->props[i].netdev before queue 
setup calls. This ensures that if queue setup fails, the cleanup function 
can find and free the allocated netdev. It also initializes lio->oct_dev 
early to prevent a crash in the cleanup path.

Patch 2 fixes an off-by-one error in the PF cleanup loop. It ensures
the current device index is cleaned up and correctly handles the 
post-loop devlink_alloc failure case.

Patch 3 fixes the same off-by-one error in the VF cleanup loop.

Signed-off-by: Zilin Guan <zilin@seu.edu.cn>

Changes in v4:
- Move the netdev initialization fix to patch 1, as it is a 
  prerequisite for the cleanup fixes.
- Change the cleanup loop to 'do { ... } while (i >= 0)' in PF and VF 
  setup_nic_devices(), as the caller guarantees octeon_dev->ifcount > 0,
  ensuring i is never decremented below 0.

Changes in v3:
- Split the off-by-one fix into separate patches for PF and VF.
- Patch 2: Decrement i in the devlink_alloc error path before jumping
  to cleanup to avoid accessing an invalid index.
- Patch 1: Initialize lio->oct_dev alongside props->netdev to prevent 
  NULL pointer dereference in cleanup_rx_oom_poll_fn().

Changes in v2:
- Add patch 2 to fix an off-by-one error in the error handling loop logic.

Zilin Guan (3):
  net: liquidio: Initialize netdev pointer before queue setup
  net: liquidio: Fix off-by-one error in PF setup_nic_devices() cleanup
  net: liquidio: Fix off-by-one error in VF setup_nic_devices() cleanup

 .../net/ethernet/cavium/liquidio/lio_main.c   | 39 ++++++++++---------
 .../ethernet/cavium/liquidio/lio_vf_main.c    |  4 +-
 2 files changed, 22 insertions(+), 21 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-30  3:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 15:44 [PATCH net v4 0/3] net: liquidio: Fix memory leaks in setup_nic_devices() Zilin Guan
2026-01-28 15:44 ` [PATCH net v4 1/3] net: liquidio: Initialize netdev pointer before queue setup Zilin Guan
2026-01-28 15:44 ` [PATCH net v4 2/3] net: liquidio: Fix off-by-one error in PF setup_nic_devices() cleanup Zilin Guan
2026-01-28 15:44 ` [PATCH net v4 3/3] net: liquidio: Fix off-by-one error in VF " Zilin Guan
2026-01-28 15:54 ` [PATCH net v4 0/3] net: liquidio: Fix memory leaks in setup_nic_devices() Kory Maincent
2026-01-30  3:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox