DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/axgbe: fix protential unreleased lock problem
@ 2021-08-26 11:30 Chengfeng Ye
  0 siblings, 0 replies; only message in thread
From: Chengfeng Ye @ 2021-08-26 11:30 UTC (permalink / raw)
  To: asomalap; +Cc: dev, Chengfeng Ye

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 acuired again. The patch is to fix this problem.

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-26 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 11:30 [dpdk-dev] [PATCH] net/axgbe: fix protential unreleased lock problem 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).