Re: [PATCH] net: liquidio: Check soft command allocation in lio_main setup_nic_devices()
From: Breno Leitao
Date: Tue Jun 23 2026 - 09:32:31 EST
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@xxxxxxxxxxxxxxx
> Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
> ---
> 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