Bug 776 - Potential error(e.g., resource leak, deadlock) due to the unreleased lock pdata->phy_mutex
Summary: Potential error(e.g., resource leak, deadlock) due to the unreleased lock pda...
Status: UNCONFIRMED
Alias: None
Product: DPDK
Classification: Unclassified
Component: ethdev (show other bugs)
Version: 20.11
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Slava
URL:
Depends on:
Blocks:
 
Reported: 2021-08-04 19:01 CEST by dg573847474
Modified: 2021-08-05 06:05 CEST (History)
0 users



Attachments

Description dg573847474 2021-08-04 19:01:29 CEST
source:
f-stack/dpdk/drivers/net/axgbe/axgbe_phy_impl.c

Hi, developers, thank you for your checking. The lock pdata->phy_mutex may not be correctly released if the phy_data->comm_owned is true and the control flow goes to the branch listed below. Finally, the method returns with the unreleased lock. The fix is to insert pthread_mutex_unlock(&pdata->phy_mutex); before returning.

static int axgbe_phy_get_comm_ownership(struct axgbe_port *pdata)
{
	struct axgbe_phy_data *phy_data = pdata->phy_data;
	uint64_t timeout;
	unsigned int mutex_id;

	/* The I2C and MDIO/GPIO bus is multiplexed between multiple devices,
	 * the driver needs to take the software mutex and then the hardware
	 * mutexes before being able to use the busses.
	 */
	pthread_mutex_lock(&pdata->phy_mutex);

	if (phy_data->comm_owned)
		return 0;  // the method returns with the unreleased lock

	...;
	return -ETIMEDOUT;
}
Comment 1 dg573847474 2021-08-04 19:45:16 CEST
source:
drivers/net/axgbe/axgbe_phy_impl.c

Note You need to log in before you can comment on or make changes to this bug.