From bc98884b1549d1a8326f427e0417cd83b6aea127 Mon Sep 17 00:00:00 2001 From: Ajay Prathi Date: Fri, 12 Jun 2020 11:58:29 +0530 Subject: [PATCH] msm: mhi_dev: Skip mhi channel state info change Fix Null pointer access when host rescans the device by not changing the channel state info if channel is already in disconnected or configured state. Change-Id: I5e897d7694f958e2b9613abfd23cbc0e975e81a3 Signed-off-by: Ajay Prathi --- drivers/platform/msm/mhi_dev/mhi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/platform/msm/mhi_dev/mhi.c b/drivers/platform/msm/mhi_dev/mhi.c index fc98fec90068..739770f2287c 100644 --- a/drivers/platform/msm/mhi_dev/mhi.c +++ b/drivers/platform/msm/mhi_dev/mhi.c @@ -2045,6 +2045,14 @@ static void mhi_update_state_info_all(enum mhi_ctrl_info info) mhi_ctx->ctrl_info = info; for (i = 0; i < MHI_MAX_SOFTWARE_CHANNELS; ++i) { + /* + * Skip channel state info change + * if channel is already in the desired state. + */ + if (channel_state_info[i].ctrl_info == info || + (info == MHI_STATE_DISCONNECTED && + channel_state_info[i].ctrl_info == MHI_STATE_CONFIGURED)) + continue; channel_state_info[i].ctrl_info = info; /* Notify kernel clients */ mhi_dev_trigger_cb(i);