Commit 2db687f3 authored by Haotian Zhang's avatar Haotian Zhang Committed by Jakub Kicinski
Browse files

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: 0f0023c6 ("ice: do not init struct ice_adapter more times than needed")
Suggested-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Suggested-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: default avatarHaotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20251001115336.1707-1-vulab@iscas.ac.cn


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7fc25c5a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment