From: Chengfeng Ye <cyeaa@connect.ust.hk>
To: asomalap@amd.com
Cc: dev@dpdk.org, Chengfeng Ye <cyeaa@connect.ust.hk>
Subject: [dpdk-dev] [PATCH v2] net/axgbe: fix potential unreleased lock problem
Date: Thu, 26 Aug 2021 12:02:58 -0700 [thread overview]
Message-ID: <20210826190258.108062-1-cyeaa@connect.ust.hk> (raw)
The lock pdata->phy_mutex may not be 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: 776
Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
drivers/net/axgbe/axgbe_phy_impl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index 02236ec192..cf39095ee4 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -418,8 +418,10 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
*/
pthread_mutex_lock(&pdata->phy_mutex);
- if (phy_data->comm_owned)
+ if (phy_data->comm_owned) {
+ pthread_mutex_unlock(&pdata->phy_mutex);
return 0;
+ }
/* Clear the mutexes */
XP_IOWRITE(pdata, XP_I2C_MUTEX, AXGBE_MUTEX_RELEASE);
@@ -444,6 +446,7 @@ static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
XP_IOWRITE(pdata, XP_MDIO_MUTEX, mutex_id);
phy_data->comm_owned = 1;
+ pthread_mutex_unlock(&pdata->phy_mutex);
return 0;
}
--
2.17.1
next reply other threads:[~2021-08-27 1:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 19:02 Chengfeng Ye [this message]
2021-09-08 13:39 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210826190258.108062-1-cyeaa@connect.ust.hk \
--to=cyeaa@connect.ust.hk \
--cc=asomalap@amd.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).