Skip to contentSkip to conversation

ufs: host: mediatek: Fix out-of-bounds access in MCQ IRQ mapping

PATCH Applied [email protected] 2 participants 3 messages Aug 4, 2025 – Aug 13, 2025

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 ufs: host: mediatek: Fix out-of-bounds access in MCQ IRQ mapping

From: Peter Wang <[email protected]>

This patch addresses a potential out-of-bounds access issue when accessing 'host->mcq_intr_info[q_index]'. The value of 'q_index' might exceed the valid array bounds if 'q_index == nr'. The condition is corrected to 'q_index >= nr' to prevent accessing invalid memory.

Fixes 66e26a4b8a77 ("scsi: ufs: host: mediatek: Set IRQ affinity policy for MCQ mode")
---
 drivers/ufs/host/ufs-mediatek.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/host/ufs-mediatek.c +1 -1
index 86ae73b89d4d..f902ce08c95a 100644
@@ -818,7 +818,7 @@ static u32 ufs_mtk_mcq_get_irq(struct ufs_hba *hba, unsigned int cpu)
 	unsigned int q_index;
 
 	q_index = map->mq_map[cpu];
-	if (q_index > nr) {
+	if (q_index >= nr) {
 		dev_err(hba->dev, "hwq index %d exceed %d\n",
 			q_index, nr);
 		return MTK_MCQ_INVALID_IRQ;
Signature · 1 line
2.45.2
#1 lore raw

Peter,

Quoted 5 lines

This patch addresses a potential out-of-bounds access issue when accessing 'host->mcq_intr_info[q_index]'. The value of 'q_index' might exceed the valid array bounds if 'q_index == nr'. The condition is corrected to 'q_index >= nr' to prevent accessing invalid memory.

Applied to 6.17/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Mon, 04 Aug 2025 14:01:54 +0800, [email protected] wrote:

This patch addresses a potential out-of-bounds access issue when accessing 'host->mcq_intr_info[q_index]'. The value of 'q_index' might exceed the valid array bounds if 'q_index == nr'. The condition is corrected to 'q_index >= nr' to prevent accessing invalid memory.

[...]

Applied to 6.17/scsi-fixes, thanks!

[1/1] ufs: host: mediatek: Fix out-of-bounds access in MCQ IRQ mapping

      https://git.kernel.org/mkp/scsi/c/7ec2bd6cd2d0
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering