Thread (2 messages) 2 messages, 2 authors, 2026-06-23

Re: [PATCH] net: liquidio: Check soft command allocation in lio_main setup_nic_devices()

From: Breno Leitao <leitao@debian.org>
Date: 2026-06-23 13:32:12
Also in: lkml, stable

On Tue, Jun 23, 2026 at 08:56:11PM +0800, Haoxiang Li wrote:
quoted hunk ↗ jump to hunk
octeon_alloc_soft_command() returns NULL when the soft command buffer
pool is empty. setup_nic_devices() dereferences the returned pointer
immediately when preparing the interface configuration command, which
can lead to a NULL pointer dereference if the pool is exhausted.

Return -ENOMEM when the allocation fails and let the existing NIC init
failure path handle the error.

Fixes: f21fb3ed364b ("Add support of Cavium Liquidio ethernet adapters")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <redacted>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 0db08ac3d098..5077129656e8 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -3363,6 +3363,9 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
 		sc = (struct octeon_soft_command *)
 			octeon_alloc_soft_command(octeon_dev, data_size,
 						  resp_size, 0);
+		if (!sc)
+			return -ENOMEM;
Is it fine to return in here, given that the
octeon_register_reqtype_free_fn()  and octeon_register_dispatch_fn()
functions succeed above? Do you need to clean any side effect by them?

--breno
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help