mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 20:10:23 +09:00
bus: mhi: host: Range check CHDBOFF and ERDBOFF
[ Upstream commit6a0c637bfe] If the value read from the CHDBOFF and ERDBOFF registers is outside the range of the MHI register space then an invalid address might be computed which later causes a kernel panic. Range check the read value to prevent a crash due to bad data from the device. Fixes:6cd330ae76("bus: mhi: core: Add support for ringing channel/event ring doorbells") Cc: stable@vger.kernel.org Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Link: https://lore.kernel.org/r/1679674384-27209-1-git-send-email-quic_jhugo@quicinc.com Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a7561c04ad
commit
2343385fe6
@@ -517,6 +517,12 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (val >= mhi_cntrl->reg_len - (8 * MHI_DEV_WAKE_DB)) {
|
||||
dev_err(dev, "CHDB offset: 0x%x is out of range: 0x%zx\n",
|
||||
val, mhi_cntrl->reg_len - (8 * MHI_DEV_WAKE_DB));
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
/* Setup wake db */
|
||||
mhi_cntrl->wake_db = base + val + (8 * MHI_DEV_WAKE_DB);
|
||||
mhi_cntrl->wake_set = false;
|
||||
@@ -534,6 +540,12 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (val >= mhi_cntrl->reg_len - (8 * mhi_cntrl->total_ev_rings)) {
|
||||
dev_err(dev, "ERDB offset: 0x%x is out of range: 0x%zx\n",
|
||||
val, mhi_cntrl->reg_len - (8 * mhi_cntrl->total_ev_rings));
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
/* Setup event db address for each ev_ring */
|
||||
mhi_event = mhi_cntrl->mhi_event;
|
||||
for (i = 0; i < mhi_cntrl->total_ev_rings; i++, val += 8, mhi_event++) {
|
||||
|
||||
Reference in New Issue
Block a user