Skip to contentSkip to conversation

net/mlx5e: Fix PTP TX SQ cleanup on metadata DB failure

PATCH In review Prathamesh Deshpande 3 participants 3 messages May 4 – May 8

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5e: Fix PTP TX SQ cleanup on metadata DB failure

mlx5e_ptp_open_txqsq() creates the hardware SQ before allocating the PTP traffic metadata database.

If mlx5e_ptp_alloc_traffic_db() fails, the error path frees the software TX queue state but skips destroying the already-created hardware SQ.

Add a dedicated unwind label that destroys the SQ before freeing the TXQ state.

Fixes 1880bc4e4a96 ("net/mlx5e: Add TX port timestamp support")
---
 drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +3 -1
index 723f66a6bd63..45db2dd7408d 100644
@@ -489,12 +489,14 @@ static int mlx5e_ptp_open_txqsq(struct mlx5e_ptp *c, u32 tisn,
 
 	err = mlx5e_ptp_alloc_traffic_db(ptpsq, dev_to_node(mlx5_core_dma_dev(c->mdev)));
 	if (err)
-		goto err_free_txqsq;
+		goto err_destroy_sq;
 
 	INIT_WORK(&ptpsq->report_unhealthy_work, mlx5e_ptpsq_unhealthy_work);
 
 	return 0;
 
+err_destroy_sq:
+	mlx5e_ptp_destroy_sq(c->mdev, txqsq->sqn);
 err_free_txqsq:
 	mlx5e_free_txqsq(txqsq);
 
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Prathamesh Deshpande

mlx5e_ptp_open_txqsq() creates the hardware SQ before allocating the PTP traffic metadata database.

If mlx5e_ptp_alloc_traffic_db() fails, the error path frees the software TX queue state but skips destroying the already-created hardware SQ.

Add a dedicated unwind label that destroys the SQ before freeing the TXQ state.

Fixes 1880bc4e4a96 ("net/mlx5e: Add TX port timestamp support")
---
  drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +1 -1
index 723f66a6bd63..45db2dd7408d 100644
@@ -489,12 +489,14 @@ static int mlx5e_ptp_open_txqsq(struct mlx5e_ptp *c, u32 tisn,
 
  	err = mlx5e_ptp_alloc_traffic_db(ptpsq, dev_to_node(mlx5_core_dma_dev(c->mdev)));
  	if (err)
-		goto err_free_txqsq;
+		goto err_destroy_sq;

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c static int mlx5e_ptp_open_txqsq(struct mlx5e_ptp *c, u32 tisn, · line 502

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c +2 -0
 
  	INIT_WORK(&ptpsq->report_unhealthy_work, mlx5e_ptpsq_unhealthy_work);
 
  	return 0;
 
+err_destroy_sq:
+	mlx5e_ptp_destroy_sq(c->mdev, txqsq->sqn);
  err_free_txqsq:
  	mlx5e_free_txqsq(txqsq);
 

Thanks.

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Prathamesh Deshpande
Quoted 11 lines · Prathamesh Deshpande

mlx5e_ptp_open_txqsq() creates the hardware SQ before allocating the PTP traffic metadata database.

If mlx5e_ptp_alloc_traffic_db() fails, the error path frees the software TX queue state but skips destroying the already-created hardware SQ.

Add a dedicated unwind label that destroys the SQ before freeing the TXQ state.

Fixes 1880bc4e4a96 ("net/mlx5e: Add TX port timestamp support")