Netdev List
 help / color / mirror / Atom feed
* [PATCH iwl-net] ice: add missing xa_destroy for sched_node_ids
@ 2026-05-14 16:55 Jacob Keller
  2026-05-15 11:53 ` [Intel-wired-lan] " Loktionov, Aleksandr
  2026-05-19 19:46 ` Simon Horman
  0 siblings, 2 replies; 3+ messages in thread
From: Jacob Keller @ 2026-05-14 16:55 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Michal Wilczynski
  Cc: intel-wired-lan, netdev, Jacob Keller

Commit 16dfa49406bc ("ice: Introduce new parameters in ice_sched_node")
added a sched_node_ids xarray to the port info structure, but never called
xa_destroy on it.

Since xarrays can allocate internal memory, this can result in a memory
leak even if every element in the xarray has been removed.

Add a call to xa_destroy the structure during ice_deinit_hw(), and one to
the unrolling cleanup path during errors in ice_init_hw(). While here,
remove the overly verbose comment explaining the nature of the
sched_node_ids xarray.

This was caught by Sashiko during development of unrelated code.

Fixes: 16dfa49406bc ("ice: Introduce new parameters in ice_sched_node")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_common.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index b617a6bff891..38d0d7e59494 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1051,14 +1051,13 @@ int ice_init_hw(struct ice_hw *hw)
 
 	hw->evb_veb = true;
 
-	/* init xarray for identifying scheduling nodes uniquely */
 	xa_init_flags(&hw->port_info->sched_node_ids, XA_FLAGS_ALLOC);
 
 	/* Query the allocated resources for Tx scheduler */
 	status = ice_sched_query_res_alloc(hw);
 	if (status) {
 		ice_debug(hw, ICE_DBG_SCHED, "Failed to get scheduler allocated resources\n");
-		goto err_unroll_alloc;
+		goto err_unroll_xarray;
 	}
 	ice_sched_get_psm_clk_freq(hw);
 
@@ -1146,6 +1145,8 @@ int ice_init_hw(struct ice_hw *hw)
 	ice_cleanup_fltr_mgmt_struct(hw);
 err_unroll_sched:
 	ice_sched_cleanup_all(hw);
+err_unroll_xarray:
+	xa_destroy(&hw->port_info->sched_node_ids);
 err_unroll_alloc:
 	devm_kfree(ice_hw_to_dev(hw), hw->port_info);
 err_unroll_cqinit:
@@ -1186,6 +1187,8 @@ void ice_deinit_hw(struct ice_hw *hw)
 
 	/* Clear VSI contexts if not already cleared */
 	ice_clear_all_vsi_ctx(hw);
+
+	xa_destroy(&hw->port_info->sched_node_ids);
 }
 
 /**

---
base-commit: c78bdba7b9666020c0832150a4fc4c0aebc7c6ac
change-id: 20260514-jk-fix-missing-xa-destroy-d3f90f3711be

Best regards,
--  
Jacob Keller <jacob.e.keller@intel.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [Intel-wired-lan] [PATCH iwl-net] ice: add missing xa_destroy for sched_node_ids
  2026-05-14 16:55 [PATCH iwl-net] ice: add missing xa_destroy for sched_node_ids Jacob Keller
@ 2026-05-15 11:53 ` Loktionov, Aleksandr
  2026-05-19 19:46 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Loktionov, Aleksandr @ 2026-05-15 11:53 UTC (permalink / raw)
  To: Keller, Jacob E, Nguyen, Anthony L, Kitszel, Przemyslaw,
	Michal Wilczynski
  Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	Keller, Jacob E



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Jacob Keller
> Sent: Thursday, May 14, 2026 6:55 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; Michal Wilczynski
> <michal.wilczynski@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Keller,
> Jacob E <jacob.e.keller@intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-net] ice: add missing xa_destroy
> for sched_node_ids
> 
> Commit 16dfa49406bc ("ice: Introduce new parameters in
> ice_sched_node") added a sched_node_ids xarray to the port info
> structure, but never called xa_destroy on it.
> 
> Since xarrays can allocate internal memory, this can result in a
> memory leak even if every element in the xarray has been removed.
> 
> Add a call to xa_destroy the structure during ice_deinit_hw(), and one
> to the unrolling cleanup path during errors in ice_init_hw(). While
> here, remove the overly verbose comment explaining the nature of the
> sched_node_ids xarray.
> 
> This was caught by Sashiko during development of unrelated code.
> 
> Fixes: 16dfa49406bc ("ice: Introduce new parameters in
> ice_sched_node")
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_common.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_common.c
> b/drivers/net/ethernet/intel/ice/ice_common.c
> index b617a6bff891..38d0d7e59494 100644
> --- a/drivers/net/ethernet/intel/ice/ice_common.c
> +++ b/drivers/net/ethernet/intel/ice/ice_common.c
> @@ -1051,14 +1051,13 @@ int ice_init_hw(struct ice_hw *hw)
> 
>  	hw->evb_veb = true;
> 
> -	/* init xarray for identifying scheduling nodes uniquely */
>  	xa_init_flags(&hw->port_info->sched_node_ids, XA_FLAGS_ALLOC);
> 
>  	/* Query the allocated resources for Tx scheduler */
>  	status = ice_sched_query_res_alloc(hw);
>  	if (status) {
>  		ice_debug(hw, ICE_DBG_SCHED, "Failed to get scheduler
> allocated resources\n");
> -		goto err_unroll_alloc;
> +		goto err_unroll_xarray;
>  	}
>  	ice_sched_get_psm_clk_freq(hw);
> 
> @@ -1146,6 +1145,8 @@ int ice_init_hw(struct ice_hw *hw)
>  	ice_cleanup_fltr_mgmt_struct(hw);
>  err_unroll_sched:
>  	ice_sched_cleanup_all(hw);
> +err_unroll_xarray:
> +	xa_destroy(&hw->port_info->sched_node_ids);
>  err_unroll_alloc:
>  	devm_kfree(ice_hw_to_dev(hw), hw->port_info);
>  err_unroll_cqinit:
> @@ -1186,6 +1187,8 @@ void ice_deinit_hw(struct ice_hw *hw)
> 
>  	/* Clear VSI contexts if not already cleared */
>  	ice_clear_all_vsi_ctx(hw);
> +
> +	xa_destroy(&hw->port_info->sched_node_ids);
>  }
> 
>  /**
> 
> ---
> base-commit: c78bdba7b9666020c0832150a4fc4c0aebc7c6ac
> change-id: 20260514-jk-fix-missing-xa-destroy-d3f90f3711be
> 
> Best regards,
> --
> Jacob Keller <jacob.e.keller@intel.com>

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH iwl-net] ice: add missing xa_destroy for sched_node_ids
  2026-05-14 16:55 [PATCH iwl-net] ice: add missing xa_destroy for sched_node_ids Jacob Keller
  2026-05-15 11:53 ` [Intel-wired-lan] " Loktionov, Aleksandr
@ 2026-05-19 19:46 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-05-19 19:46 UTC (permalink / raw)
  To: Jacob Keller
  Cc: Tony Nguyen, Przemek Kitszel, Michal Wilczynski, intel-wired-lan,
	netdev

On Thu, May 14, 2026 at 09:55:21AM -0700, Jacob Keller wrote:
> Commit 16dfa49406bc ("ice: Introduce new parameters in ice_sched_node")
> added a sched_node_ids xarray to the port info structure, but never called
> xa_destroy on it.
> 
> Since xarrays can allocate internal memory, this can result in a memory
> leak even if every element in the xarray has been removed.
> 
> Add a call to xa_destroy the structure during ice_deinit_hw(), and one to
> the unrolling cleanup path during errors in ice_init_hw(). While here,
> remove the overly verbose comment explaining the nature of the
> sched_node_ids xarray.
> 
> This was caught by Sashiko during development of unrelated code.
> 
> Fixes: 16dfa49406bc ("ice: Introduce new parameters in ice_sched_node")
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-19 19:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 16:55 [PATCH iwl-net] ice: add missing xa_destroy for sched_node_ids Jacob Keller
2026-05-15 11:53 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-05-19 19:46 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox