Re: [PATCH v7 1/5] net/mlx5: free mlx5_st_idx_data on final dealloc

From
Michael Gur <hidden>
Date
2026-06-14 07:06:46
Also in
dri-devel, kvm, linux-pci, linux-rdma
Reply to
Zhiping Zhang, 2026-06-11
On 6/11/2026 7:11 PM, Zhiping Zhang wrote:
quoted hunk ↗ jump to hunk
When the last reference to an ST table entry is dropped,
mlx5_st_dealloc_index() removed the entry from idx_xa but leaked the
backing mlx5_st_idx_data allocation. Repeated alloc/dealloc cycles
therefore accumulate one struct mlx5_st_idx_data per cycle.

Free idx_data after the xa_erase() so the lifetime of the bookkeeping
struct matches the lifetime of the ST entry it tracks.

Fixes: 888a7776f4fb ("net/mlx5: Add support for device steering tag")
Signed-off-by: Zhiping Zhang <redacted>
---
  drivers/net/ethernet/mellanox/mlx5/core/lib/st.c | 1 +
  1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/st.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/st.c
index 997be91f0a13..7cedc348790d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/st.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/st.c
@@ -175,6 +175,7 @@ int mlx5_st_dealloc_index(struct mlx5_core_dev *dev, u16 st_index)
  
  	if (refcount_dec_and_test(&idx_data->usecount)) {
  		xa_erase(&st->idx_xa, st_index);
+		kfree(idx_data);
  		/* We leave PCI config space as was before, no mkey will refer to it */
  	}
  
Reviewed-by: Michael Gur <redacted>

Thanks.
Thread (11 messages) 11 messages, 3 authors, last reply 2026-06-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help