DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] net/mlx5: fix potential unreleased lock problem
@ 2021-08-26 18:56 Chengfeng Ye
  2021-08-26 19:06 ` [dpdk-dev] 回复: " YE Chengfeng
  0 siblings, 1 reply; 4+ messages in thread
From: Chengfeng Ye @ 2021-08-26 18:56 UTC (permalink / raw)
  To: asomalap; +Cc: dev, Chengfeng Ye

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 <cyeaa@connect.ust.hk>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] 回复: [PATCH v2] net/mlx5: fix potential unreleased lock problem
  2021-08-26 18:56 [dpdk-dev] [PATCH v2] net/mlx5: fix potential unreleased lock problem Chengfeng Ye
@ 2021-08-26 19:06 ` YE Chengfeng
  2021-08-30  7:59   ` [dpdk-dev] " Slava Ovsiienko
  0 siblings, 1 reply; 4+ messages in thread
From: YE Chengfeng @ 2021-08-26 19:06 UTC (permalink / raw)
  To: asomalap; +Cc: dev

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

Thanks,
Chengfeng
________________________________
发件人: YE Chengfeng <cyeaa@connect.ust.hk>
发送时间: 2021年8月27日 2:56
收件人: asomalap@amd.com <asomalap@amd.com>
抄送: dev@dpdk.org <dev@dpdk.org>; YE Chengfeng <cyeaa@connect.ust.hk>
主题: [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 <cyeaa@connect.ust.hk>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/mlx5: fix potential unreleased lock problem
  2021-08-26 19:06 ` [dpdk-dev] 回复: " YE Chengfeng
@ 2021-08-30  7:59   ` Slava Ovsiienko
  0 siblings, 0 replies; 4+ messages in thread
From: Slava Ovsiienko @ 2021-08-30  7:59 UTC (permalink / raw)
  To: YE Chengfeng, asomalap; +Cc: dev

Hi, Chengfeng

Thank you for the fix, we can adopt this (ie Upstream ML is not "wrong place" 😊)
I have some minor comment about:
- the problem should be described in past tense (should b e"sh->txpp.mutex WAS not correctly")
- headline should be more specific, like "fix mutex unlock in txpp cleanup")
- "Fixes:" tag should be present
- Cc: stable@dpdk.org  should be present

Could you, please, update and send v3 ?

With best regards,
Slava

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of YE Chengfeng
> Sent: Thursday, August 26, 2021 22:06
> To: asomalap@amd.com
> Cc: dev@dpdk.org
> Subject: [dpdk-dev] 回复: [PATCH v2] net/mlx5: fix potential unreleased lock
> problem
> 
> It seems that I send this patch to a wrong place,  please just ignore it.
> 
> Thanks,
> Chengfeng
> ________________________________
> 发件人: YE Chengfeng <cyeaa@connect.ust.hk>
> 发送时间: 2021年8月27日 2:56
> 收件人: asomalap@amd.com <asomalap@amd.com>
> 抄送: dev@dpdk.org <dev@dpdk.org>; YE Chengfeng
> <cyeaa@connect.ust.hk>
> 主题: [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 <cyeaa@connect.ust.hk>
> ---
>  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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH v2] net/mlx5: fix potential unreleased lock problem
@ 2021-08-26 18:55 Chengfeng Ye
  0 siblings, 0 replies; 4+ messages in thread
From: Chengfeng Ye @ 2021-08-26 18:55 UTC (permalink / raw)
  To: matan, viacheslavo, tzahio; +Cc: dev, Chengfeng Ye

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 <cyeaa@connect.ust.hk>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-30  8:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 18:56 [dpdk-dev] [PATCH v2] net/mlx5: fix potential unreleased lock problem Chengfeng Ye
2021-08-26 19:06 ` [dpdk-dev] 回复: " YE Chengfeng
2021-08-30  7:59   ` [dpdk-dev] " Slava Ovsiienko
  -- strict thread matches above, loose matches on Subject: below --
2021-08-26 18:55 Chengfeng Ye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).