提交 3c54a3ff 编写于 作者: D Dan Carpenter 提交者: Manivannan Sadhasivam

bus: mhi: ep: Fix off by one in mhi_ep_process_cmd_ring()

The > comparison should be changed to >= to prevent an out of bounds
access into the mhi_cntrl->mhi_chan[] array.  The mhi_cntrl->mhi_chan[]
array is allocated in mhi_ep_chan_init() and has mhi_cntrl->max_chan
elements.

Fixes: 6de4941c ("bus: mhi: ep: Check if the channel is supported by the controller")
Signed-off-by: NDan Carpenter <error27@gmail.com>
Reviewed-by: NManivannan Sadhasivam <mani@kernel.org>
Reviewed-by: NAlex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/Y9JH5sudiZWvbODv@kiliSigned-off-by: NManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
上级 1ddc7618
...@@ -125,7 +125,7 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele ...@@ -125,7 +125,7 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele
ch_id = MHI_TRE_GET_CMD_CHID(el); ch_id = MHI_TRE_GET_CMD_CHID(el);
/* Check if the channel is supported by the controller */ /* Check if the channel is supported by the controller */
if ((ch_id > mhi_cntrl->max_chan) || !mhi_cntrl->mhi_chan[ch_id].name) { if ((ch_id >= mhi_cntrl->max_chan) || !mhi_cntrl->mhi_chan[ch_id].name) {
dev_err(dev, "Channel (%u) not supported!\n", ch_id); dev_err(dev, "Channel (%u) not supported!\n", ch_id);
return -ENODEV; return -ENODEV;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册