Thread (3 messages) 3 messages, 2 authors, 2021-08-30

[dpdk-dev] 回复: [PATCH v2] net/mlx5: fix potential unreleased lock problem

From: YE Chengfeng <hidden>
Date: 2021-08-27 01:23:16
Subsystem: networking drivers, the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

It seems that I send this patch to a wrong place,  please just ignore it.

Thanks,
Chengfeng
________________________________
发件人: YE Chengfeng [off-list ref]
发送时间: 2021年8月27日 2:56
收件人: asomalap@amd.com [off-list ref]
抄送: dev@dpdk.org [off-list ref]; YE Chengfeng [off-list ref]
主题: [PATCH v2] net/mlx5: fix potential unreleased lock problem

The lock sh->txpp.mutex isn't correctly released if the function
return in these two branches, which may lead to deadlock if the
lock is acquired again.

Cc: cyeaa@connect.ust.hk
Bugzilla ID: 774

Signed-off-by: Chengfeng Ye <redacted>
---
 drivers/net/mlx5/mlx5_txpp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
index 4f6da9f2d1..0ece788a84 100644
--- a/drivers/net/mlx5/mlx5_txpp.c
+++ b/drivers/net/mlx5/mlx5_txpp.c
@@ -961,8 +961,12 @@ mlx5_txpp_stop(struct rte_eth_dev *dev)
         MLX5_ASSERT(!ret);
         RTE_SET_USED(ret);
         MLX5_ASSERT(sh->txpp.refcnt);
-       if (!sh->txpp.refcnt || --sh->txpp.refcnt)
+       if (!sh->txpp.refcnt || --sh->txpp.refcnt) {
+               ret = pthread_mutex_unlock(&sh->txpp.mutex);
+               MLX5_ASSERT(!ret);
+               RTE_SET_USED(ret);
                 return;
+       }
         /* No references any more, do actual destroy. */
         mlx5_txpp_destroy(sh);
         ret = pthread_mutex_unlock(&sh->txpp.mutex);
--
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help