Skip to contentSkip to conversation

net/axgbe: fix potential unreleased lock problem in axgbe_i2c_xfer

PATCH Applied Chengfeng Ye 2 participants 2 messages Aug 27, 2021 – Sep 8, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/axgbe: fix potential unreleased lock problem in axgbe_i2c_xfer

The lock pdata->i2c_mutex is not released if the function return in these two patched branches, which may lead to deadlock problem if this lock is acquired again.

Cc: [email protected]
Bugzilla ID: 777

---
 drivers/net/axgbe/axgbe_i2c.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/axgbe/axgbe_i2c.c +2 -0
index ab3738a12e..a2798f484e 100644
@@ -233,6 +233,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
 	ret = axgbe_i2c_disable(pdata);
 	if (ret) {
 		PMD_DRV_LOG(ERR, "failed to disable i2c master\n");
+		pthread_mutex_unlock(&pdata->i2c_mutex);
 		return ret;
 	}
 
@@ -249,6 +250,7 @@ static int axgbe_i2c_xfer(struct axgbe_port *pdata, struct axgbe_i2c_op *op)
 	ret = axgbe_i2c_enable(pdata);
 	if (ret) {
 		PMD_DRV_LOG(ERR, "failed to enable i2c master\n");
+		pthread_mutex_unlock(&pdata->i2c_mutex);
 		return ret;
 	}
 
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1 Applied
#1 lore raw
Quoted 8 lines · Chengfeng Ye

The lock pdata->i2c_mutex is not released if the function return in these two patched branches, which may lead to deadlock problem if this lock is acquired again.

Cc: [email protected]
Bugzilla ID: 777

Bugzilla ID: 777

Fixes 4ac7516b8b39 ("net/axgbe: add phy init and related APIs")

Patch title updated as following while merging:
net/axgbe: fix unreleased lock in I2C transfer

Applied to dpdk-next-net/main, thanks.