* [PATCH] net: liquidio: Check soft command allocation in lio_main setup_nic_devices()
@ 2026-06-23 12:56 Haoxiang Li
2026-06-23 13:31 ` Breno Leitao
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-06-23 12:56 UTC (permalink / raw)
To: andrew+netdev, davem, kuba, pabeni, kory.maincent, zilin, petrm,
u.kleine-koenig, marco.crivellari, vadim.fedorenko,
Aleksey.Makarov, satananda.burla, felix.manlunas, derek.chickles,
rvatsavayi
Cc: netdev, linux-kernel, Haoxiang Li, stable
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 <haoxiang_li2024@163.com>
---
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;
+
resp = (struct liquidio_if_cfg_resp *)sc->virtrptr;
vdata = (struct lio_version *)sc->virtdptr;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: liquidio: Check soft command allocation in lio_main setup_nic_devices()
2026-06-23 12:56 [PATCH] net: liquidio: Check soft command allocation in lio_main setup_nic_devices() Haoxiang Li
@ 2026-06-23 13:31 ` Breno Leitao
0 siblings, 0 replies; 2+ messages in thread
From: Breno Leitao @ 2026-06-23 13:31 UTC (permalink / raw)
To: Haoxiang Li
Cc: andrew+netdev, davem, kuba, pabeni, kory.maincent, zilin, petrm,
u.kleine-koenig, marco.crivellari, vadim.fedorenko,
Aleksey.Makarov, satananda.burla, felix.manlunas, derek.chickles,
rvatsavayi, netdev, linux-kernel, stable
On Tue, Jun 23, 2026 at 08:56:11PM +0800, Haoxiang Li wrote:
> 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 <haoxiang_li2024@163.com>
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-23 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 12:56 [PATCH] net: liquidio: Check soft command allocation in lio_main setup_nic_devices() Haoxiang Li
2026-06-23 13:31 ` Breno Leitao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.