]> Gentwo Git Trees - linux/.git/commit
ice: ice_adapter: release xa entry on adapter allocation failure
authorHaotian Zhang <vulab@iscas.ac.cn>
Wed, 1 Oct 2025 11:53:36 +0000 (19:53 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 6 Oct 2025 18:16:05 +0000 (11:16 -0700)
commit2db687f3469dbc5c59bc53d55acafd75d530b497
tree7175481303c13d77d141a73e8b91dafdbe72fd6f
parent7fc25c5a5ae6230d14b4c088fc94dbd58b2a9f3a
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 <przemyslaw.kitszel@intel.com>
Suggested-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20251001115336.1707-1-vulab@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_adapter.c