]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
scsi: ufs: core: Fix shift out of bounds when MAXQ=32
authorwangshuaiwei <wangshuaiwei1@xiaomi.com>
Tue, 24 Feb 2026 06:32:28 +0000 (14:32 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 24 Feb 2026 19:23:07 +0000 (14:23 -0500)
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>
drivers/ufs/core/ufshcd.c

index 85987373b96176d419fa8a838f8e7ffd55b79506..899e663fea6e88e8f05e725d84b392b6cd3ec200 100644 (file)
@@ -7110,7 +7110,7 @@ static irqreturn_t ufshcd_handle_mcq_cq_events(struct ufs_hba *hba)
 
        ret = ufshcd_vops_get_outstanding_cqs(hba, &outstanding_cqs);
        if (ret)
-               outstanding_cqs = (1U << hba->nr_hw_queues) - 1;
+               outstanding_cqs = (1ULL << hba->nr_hw_queues) - 1;
 
        /* Exclude the poll queues */
        nr_queues = hba->nr_hw_queues - hba->nr_queues[HCTX_TYPE_POLL];