diff mbox series

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

Message ID 20200413120741.2832-2-manivannan.sadhasivam@linaro.org (mailing list archive)
State New, archived
Headers show
Series [1/2] bus: mhi: core: Fix parsing of mhi_flags | expand

Commit Message

Manivannan Sadhasivam April 13, 2020, 12:07 p.m. UTC
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@oracle.com>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/core/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

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;