[PATCH 2/2] bus: mhi: core: Fix double lock of 'mhi_chan->lock'

From: Manivannan Sadhasivam
Date: Mon Apr 13 2020 - 08:17:24 EST


mhi_queue_buf() will grab the 'mhi_chan->lock' for doing the doorbell
access. Hence the lock needs to be dropped before the call.

Fixes: 189ff97cca53 ("bus: mhi: core: Add support for data transfer")
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
---
drivers/bus/mhi/core/main.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index 4165a853c189..ed995137c3a0 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -538,6 +538,11 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
* from dropping the packet
*/
if (mhi_chan->pre_alloc) {
+ /*
+ * mhi_queue_buf() will grab the mhi_chan->lock
+ * so let's drop it here and grab it later
+ */
+ read_unlock_bh(&mhi_chan->lock);
if (mhi_queue_buf(mhi_chan->mhi_dev,
mhi_chan->dir,
buf_info->cb_buf,
@@ -547,6 +552,7 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl,
mhi_chan->chan);
kfree(buf_info->cb_buf);
}
+ read_lock_bh(&mhi_chan->lock);
}
}
break;
--
2.17.1