Skip to contentSkip to conversation

bus: mhi: core: Remove double locking from mhi_driver_remove()

PATCH Applied Bhaumik Bhatt 3 participants 4 messages Oct 15, 2020 – Dec 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: mhi: core: Remove double locking from mhi_driver_remove()

There is double acquisition of the pm_lock from mhi_driver_remove() function. Remove the read_lock_bh/read_unlock_bh calls for pm_lock taken during a call to mhi_device_put() as the lock is acquired within the function already. This will help avoid a potential kernel panic.

Fixes 189ff97cca53 ("bus: mhi: core: Add support for data transfer")
---
 drivers/bus/mhi/core/init.c | 2 --
 1 file changed, 2 deletions(-)
drivers/bus/mhi/core/init.c +0 -2
index 0ffdebd..0a09f82 100644
@@ -1276,10 +1276,8 @@ static int mhi_driver_remove(struct device *dev)
 		mutex_unlock(&mhi_chan->mutex);
 	}
 
-	read_lock_bh(&mhi_cntrl->pm_lock);
 	while (mhi_dev->dev_wake)
 		mhi_device_put(mhi_dev);
-	read_unlock_bh(&mhi_cntrl->pm_lock);
 
 	return 0;
 }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Bhaumik Bhatt

There is double acquisition of the pm_lock from mhi_driver_remove() function. Remove the read_lock_bh/read_unlock_bh calls for pm_lock taken during a call to mhi_device_put() as the lock is acquired within the function already. This will help avoid a potential kernel panic.

Fixes 189ff97cca53 ("bus: mhi: core: Add support for data transfer")

Thanks,
Mani

Quoted 23 lines
---
 drivers/bus/mhi/core/init.c | 2 --
 1 file changed, 2 deletions(-)
drivers/bus/mhi/core/init.c +0 -2
index 0ffdebd..0a09f82 100644
@@ -1276,10 +1276,8 @@ static int mhi_driver_remove(struct device *dev)
 		mutex_unlock(&mhi_chan->mutex);
 	}
 
-	read_lock_bh(&mhi_cntrl->pm_lock);
 	while (mhi_dev->dev_wake)
 		mhi_device_put(mhi_dev);
-	read_unlock_bh(&mhi_cntrl->pm_lock);
 
 	return 0;
 }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw
In reply to Bhaumik Bhatt
Quoted 9 lines · Bhaumik Bhatt

There is double acquisition of the pm_lock from mhi_driver_remove() function. Remove the read_lock_bh/read_unlock_bh calls for pm_lock taken during a call to mhi_device_put() as the lock is acquired within the function already. This will help avoid a potential kernel panic.

Fixes 189ff97cca53 ("bus: mhi: core: Add support for data transfer")

Applied to mhi-next!

Thanks,
Mani

Quoted 23 lines
---
 drivers/bus/mhi/core/init.c | 2 --
 1 file changed, 2 deletions(-)
drivers/bus/mhi/core/init.c +0 -2
index 0ffdebd..0a09f82 100644
@@ -1276,10 +1276,8 @@ static int mhi_driver_remove(struct device *dev)
 		mutex_unlock(&mhi_chan->mutex);
 	}
 
-	read_lock_bh(&mhi_cntrl->pm_lock);
 	while (mhi_dev->dev_wake)
 		mhi_device_put(mhi_dev);
-	read_unlock_bh(&mhi_cntrl->pm_lock);
 
 	return 0;
 }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw
In reply to Bhaumik Bhatt
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 11 lines · On Thu, 15 Oct 2020 11:47:51 -0700 you wrote:

There is double acquisition of the pm_lock from mhi_driver_remove() function. Remove the read_lock_bh/read_unlock_bh calls for pm_lock taken during a call to mhi_device_put() as the lock is acquired within the function already. This will help avoid a potential kernel panic.

Fixes 189ff97cca53 ("bus: mhi: core: Add support for data transfer")

[...]

Here is the summary with links:
- bus: mhi: core: Remove double locking from mhi_driver_remove()

    https://git.kernel.org/qcom/c/9b627c25e708

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html