net/bnxt: fix deadlock in mgr timer cb

Message ID tencent_7B6D2301220A31DB3CA9A701112E3A47DF08@qq.com (mailing list archive)
State Accepted
Delegated to: Ajit Khaparde
Headers
Series net/bnxt: fix deadlock in mgr timer cb |

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-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Weiguo Li Nov. 4, 2023, 4:06 a.m. UTC
  The function 'ulp_ha_mgr_timer_cb' acquires a lock on the context
entry at the beginning with bnxt_ulp_cntxt_entry_acquire(). This lock
is expected to be released by bnxt_ulp_cntxt_entry_release() at the
end of the function.

However, the second early return statement in the function could
potentially bypass the lock release. To fix this issue, add
bnxt_ulp_cntxt_entry_release() before the return statement.

Fixes: 1993b267dbcb ("net/bnxt: cleanup ULP parser and mapper)
CC: stable@dpdk.org

Signed-off-by: Weiguo Li <liweiguo@xencore.cn>
---
 drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Ajit Khaparde Feb. 8, 2024, 9:45 p.m. UTC | #1
On Fri, Nov 3, 2023 at 9:07 PM Weiguo Li <liwg06@foxmail.com> wrote:
>
> The function 'ulp_ha_mgr_timer_cb' acquires a lock on the context
> entry at the beginning with bnxt_ulp_cntxt_entry_acquire(). This lock
> is expected to be released by bnxt_ulp_cntxt_entry_release() at the
> end of the function.
>
> However, the second early return statement in the function could
> potentially bypass the lock release. To fix this issue, add
> bnxt_ulp_cntxt_entry_release() before the return statement.
>
> Fixes: 1993b267dbcb ("net/bnxt: cleanup ULP parser and mapper)
> CC: stable@dpdk.org
>
> Signed-off-by: Weiguo Li <liweiguo@xencore.cn>

Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

Fixed up the author and signed-off-by mismatch and merged in
brcm-next-net for-next-net branch.

> ---
>  drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
> index f3f5bda890..852deef3b4 100644
> --- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
> +++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
> @@ -253,6 +253,7 @@ ulp_ha_mgr_timer_cb(void *arg)
>
>         myclient_cnt = bnxt_ulp_cntxt_num_shared_clients_get(ulp_ctx);
>         if (myclient_cnt == 0) {
> +               bnxt_ulp_cntxt_entry_release();
>                 BNXT_TF_DBG(ERR,
>                             "PANIC Client Count is zero kill timer\n.");
>                 return;
> --
> 2.34.1
>
  

Patch

diff --git a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
index f3f5bda890..852deef3b4 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_ha_mgr.c
@@ -253,6 +253,7 @@  ulp_ha_mgr_timer_cb(void *arg)
 
 	myclient_cnt = bnxt_ulp_cntxt_num_shared_clients_get(ulp_ctx);
 	if (myclient_cnt == 0) {
+		bnxt_ulp_cntxt_entry_release();
 		BNXT_TF_DBG(ERR,
 			    "PANIC Client Count is zero kill timer\n.");
 		return;