> -----Original Message-----
> From: Intel-wired-lan <[email protected]> On Behalf
> Of Haotian Zhang
> Sent: Wednesday, October 1, 2025 1:54 PM
> To: Keller, Jacob E <[email protected]>; Nguyen, Anthony L
> <[email protected]>; Kitszel, Przemyslaw
> <[email protected]>
> Cc: Andrew Lunn <[email protected]>; David S . Miller
> <[email protected]>; Eric Dumazet <[email protected]>; Jakub
> Kicinski <[email protected]>; Paolo Abeni <[email protected]>; intel-
> [email protected]; [email protected]; linux-
> [email protected]; Haotian Zhang <[email protected]>
> Subject: [Intel-wired-lan] [PATCH v3] ice: ice_adapter: release xa
> entry on adapter allocation failure
>
> When ice_adapter_new() fails, the reserved XArray entry created by
> xa_insert() is not released. This causes subsequent insertions at
> the same index to return -EBUSY, potentially leading to
> NULL pointer dereferences.
>
> Reorder the operations as suggested by Przemek Kitszel:
> 1. Check if adapter already exists (xa_load)
> 2. Reserve the XArray slot (xa_reserve)
> 3. Allocate the adapter (ice_adapter_new)
> 4. Store the adapter (xa_store)
>
> Fixes: 0f0023c649c7 ("ice: do not init struct ice_adapter more times
> than needed")
> Suggested-by: Przemek Kitszel <[email protected]>
> Suggested-by: Jacob Keller <[email protected]>
> Signed-off-by: Haotian Zhang <[email protected]>
Reviewed-by: Aleksandr Loktionov <[email protected]>
>
> ---
> Changes in v3:
> - Reorder xa_load/xa_reserve/ice_adapter_new/xa_store calls as
> suggested by Przemek Kitszel, instead of just adding xa_release().
> Changes in v2:
> - Instead of checking the return value of xa_store(), fix the real
> bug
> where a failed ice_adapter_new() would leave a stale entry in the
> XArray.
> - Use xa_release() to clean up the reserved entry, as suggested by
> Jacob Keller.
> ---
...
> --
> 2.50.1.windows.1