net/mlx5: fix the unlock mismatch issue

Message ID tencent_D1651EC7D3B588081DFD6FF1112691E61807@qq.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix the unlock mismatch issue |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Weiguo Li Nov. 4, 2023, 4:07 a.m. UTC
  The 'need_lock' parameter controls whether the function acquires and
releases the spinlock, but the first unlock operation occurs regardless
of the 'need_lock' parameter.

To fix this issue, the spin unlock operation should be invoked within
an 'if (need_lock)' block, ensuring that the function only unlocks the
spinlock if it has previously been acquired.

Fixes: 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action with HWS")
Cc: stable@dpdk.org

Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
---
 drivers/net/mlx5/mlx5_flow_aso.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Slava Ovsiienko Nov. 7, 2023, 6:52 a.m. UTC | #1
Hi, Weiguo

Good catch, thank you.

With best regards,
Slava

> -----Original Message-----
> From: Weiguo Li <liwg06@foxmail.com>
> Sent: Saturday, November 4, 2023 6:08 AM
> To: Alexander Kozyrev <akozyrev@nvidia.com>
> Cc: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org;
> stable@dpdk.org; Weiguo Li <liweiguo@xencore.cn>
> Subject: [PATCH] net/mlx5: fix the unlock mismatch issue
> 
> The 'need_lock' parameter controls whether the function acquires and
> releases the spinlock, but the first unlock operation occurs regardless of the
> 'need_lock' parameter.
> 
> To fix this issue, the spin unlock operation should be invoked within an 'if
> (need_lock)' block, ensuring that the function only unlocks the spinlock if it
> has previously been acquired.
> 
> Fixes: 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action
> with HWS")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  
Raslan Darawsheh Nov. 12, 2023, 2:23 p.m. UTC | #2
Hi,

> -----Original Message-----
> From: Weiguo Li <liwg06@foxmail.com>
> Sent: Saturday, November 4, 2023 6:08 AM
> To: Alexander Kozyrev <akozyrev@nvidia.com>
> Cc: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org;
> stable@dpdk.org; Weiguo Li <liweiguo@xencore.cn>
> Subject: [PATCH] net/mlx5: fix the unlock mismatch issue
> 
> The 'need_lock' parameter controls whether the function acquires and
> releases the spinlock, but the first unlock operation occurs regardless of the
> 'need_lock' parameter.
> 
> To fix this issue, the spin unlock operation should be invoked within an 'if
> (need_lock)' block, ensuring that the function only unlocks the spinlock if it
> has previously been acquired.
> 
> Fixes: 48fbb0e93d06 ("net/mlx5: support flow meter mark indirect action
> with HWS")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Weiguo Li <liweiguo@xencore.cn>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_aso.c b/drivers/net/mlx5/mlx5_flow_aso.c
index 3c08da0614..f311443472 100644
--- a/drivers/net/mlx5/mlx5_flow_aso.c
+++ b/drivers/net/mlx5/mlx5_flow_aso.c
@@ -932,7 +932,8 @@  mlx5_aso_mtr_completion_handle(struct mlx5_aso_sq *sq, bool need_lock)
 		rte_spinlock_lock(&sq->sqsl);
 	max = (uint16_t)(sq->head - sq->tail);
 	if (unlikely(!max)) {
-		rte_spinlock_unlock(&sq->sqsl);
+		if (need_lock)
+			rte_spinlock_unlock(&sq->sqsl);
 		return;
 	}
 	do {