Skip to content

Commit

Permalink
bus: mhi: ep: Fix off by one in mhi_ep_process_cmd_ring()
Browse files Browse the repository at this point in the history
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: 6de4941 ("bus: mhi: ep: Check if the channel is supported by the controller")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/Y9JH5sudiZWvbODv@kili
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
  • Loading branch information
Dan Carpenter authored and Manivannan Sadhasivam committed Feb 2, 2023
1 parent 1ddc761 commit 3c54a3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/bus/mhi/ep/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/* 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);
return -ENODEV;
}
Expand Down

0 comments on commit 3c54a3f

Please sign in to comment.