[PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller

Manivannan Sadhasivam posted 6 patches 2 years, 8 months ago
[PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller
Posted by Manivannan Sadhasivam 2 years, 8 months ago
Before processing the command ring for the channel, check if the channel is
supported by the controller or not.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/bus/mhi/ep/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 55209d42a995..8b065a3cc848 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -123,6 +123,13 @@ static int mhi_ep_process_cmd_ring(struct mhi_ep_ring *ring, struct mhi_ring_ele
 	int ret;
 
 	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) {
+		dev_err(dev, "Channel (%u) not supported!\n", ch_id);
+		return -ENODEV;
+	}
+
 	mhi_chan = &mhi_cntrl->mhi_chan[ch_id];
 	ch_ring = &mhi_cntrl->mhi_chan[ch_id].ring;
 
-- 
2.25.1
Re: [PATCH 2/6] bus: mhi: ep: Check if the channel is supported by the controller
Posted by Jeffrey Hugo 2 years, 8 months ago
On 12/28/2022 9:17 AM, Manivannan Sadhasivam wrote:
> Before processing the command ring for the channel, check if the channel is
> supported by the controller or not.
> 
> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>