Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: ufs: core: Fix shift out of bounds when MAXQ=32

According to JESD223F, the maximum number of queues (MAXQ) is 32. When MCQ
is enabled and ESI is disabled, nr_hw_queues=32 causes a shift overflow
problem.

Fix this by using 64-bit intermediate values to handle the nr_hw_queues=32
case safely.

Signed-off-by: wangshuaiwei <wangshuaiwei1@xiaomi.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260224063228.50112-1-wangshuaiwei1@xiaomi.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

wangshuaiwei and committed by
Martin K. Petersen
2f38fd99 62c01537

+1 -1
+1 -1
drivers/ufs/core/ufshcd.c
··· 7110 7110 7111 7111 ret = ufshcd_vops_get_outstanding_cqs(hba, &outstanding_cqs); 7112 7112 if (ret) 7113 - outstanding_cqs = (1U << hba->nr_hw_queues) - 1; 7113 + outstanding_cqs = (1ULL << hba->nr_hw_queues) - 1; 7114 7114 7115 7115 /* Exclude the poll queues */ 7116 7116 nr_queues = hba->nr_hw_queues - hba->nr_queues[HCTX_TYPE_POLL];