[v2] net/axgbe: fix potential unreleased lock problem in axgbe_i2c_xfer

Message ID 20210826185559.107237-1-cyeaa@connect.ust.hk (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/axgbe: fix potential unreleased lock problem in axgbe_i2c_xfer |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

YE Chengfeng Aug. 26, 2021, 6:55 p.m. UTC
  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: cyeaa@connect.ust.hk
Bugzilla ID: 777

Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>
---
 drivers/net/axgbe/axgbe_i2c.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Ferruh Yigit Sept. 8, 2021, 1:31 p.m. UTC | #1
On 8/26/2021 7:55 PM, Chengfeng Ye wrote:
> 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: cyeaa@connect.ust.hk
> Bugzilla ID: 777
> 
> Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

    Bugzilla ID: 777
    Fixes: 4ac7516b8b39 ("net/axgbe: add phy init and related APIs")
    Cc: stable@dpdk.org

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


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

Patch

diff --git a/drivers/net/axgbe/axgbe_i2c.c b/drivers/net/axgbe/axgbe_i2c.c
index ab3738a12e..a2798f484e 100644
--- a/drivers/net/axgbe/axgbe_i2c.c
+++ b/drivers/net/axgbe/axgbe_i2c.c
@@ -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;
 	}