mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: mhi: ep: Fix off by one in  mhi_ep_process_cmd_ring()
@ 2023-01-26  9:29 Dan Carpenter
  2023-01-26 13:26 ` Alex Elder
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dan Carpenter @ 2023-01-26  9:29 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: Alex Elder, Greg Kroah-Hartman, Jeffrey Hugo, mhi, linux-arm-msm,
	kernel-janitors

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: 2527ad44ddb2 ("bus: mhi: ep: Check if the channel is supported by the controller")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/bus/mhi/ep/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index bcaaba97ef63..be2d56e7f392 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -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;
 	}
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-27  7:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26  9:29 [PATCH] bus: mhi: ep: Fix off by one in mhi_ep_process_cmd_ring() Dan Carpenter
2023-01-26 13:26 ` Alex Elder
2023-01-27  6:48   ` Manivannan Sadhasivam
2023-01-27  6:46 ` Manivannan Sadhasivam
2023-01-27  6:59 ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).