mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-15 01:01:56 -04:00
mhi: core: Add range check for channel id received in event ring
The mhi_process_cmd_completion function reads cmd channel id from cmd_pkt using MHI_TRE_GET_CHID, the value is under the control of MHI devices and can be any value between 0 and 255. However the max channel is defined in device tree file and it is usually smaller than 255. This can cause out of bound access to the channel array. Fix this by checking the channel id received in cmd ring against the max channel allowed on target. Change-Id: Ib6faf67c7eae67186b3a44e6b1612deff6bf05fa Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
This commit is contained in:
parent
34c9ed3cc4
commit
b99432af45
1 changed files with 5 additions and 0 deletions
|
|
@ -1160,6 +1160,10 @@ static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl,
|
|||
complete(&mhi_tsync->completion);
|
||||
} else {
|
||||
chan = MHI_TRE_GET_CMD_CHID(cmd_pkt);
|
||||
if (chan >= mhi_cntrl->max_chan) {
|
||||
MHI_ERR("invalid channel id %u\n", chan);
|
||||
goto del_ring_el;
|
||||
}
|
||||
mhi_chan = &mhi_cntrl->mhi_chan[chan];
|
||||
write_lock_bh(&mhi_chan->lock);
|
||||
mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre);
|
||||
|
|
@ -1167,6 +1171,7 @@ static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl,
|
|||
write_unlock_bh(&mhi_chan->lock);
|
||||
}
|
||||
|
||||
del_ring_el:
|
||||
mhi_del_ring_element(mhi_cntrl, mhi_ring);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue