UPSTREAM: scsi: ufs: core: Fix divide by zero in ufshcd_map_queues()

Before calling blk_mq_map_queues(), the mq_map and nr_queues belonging to
struct blk_mq_queue_map must have a valid value.

If nr_queues is set to 0, the system may encounter a divide by zero
depending on the type of architecture.

    blk_mq_map_queues() -> queue_index()

Link: https://lore.kernel.org/r/1891546521.01644873481638.JavaMail.epsvc@epcpadp4
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 234653003
(cherry picked from commit 10af115646)
Change-Id: Iaf94a3fe8200fdfc336e5951fcbb760a1de3dd1d
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
Jinyoung Choi
2022-02-14 19:33:52 +09:00
committed by Bart Van Assche
parent d99b8a625f
commit fa0e3961cc

View File

@@ -2741,7 +2741,7 @@ static int ufshcd_map_queues(struct Scsi_Host *shost)
break;
case HCTX_TYPE_READ:
map->nr_queues = 0;
break;
continue;
default:
WARN_ON_ONCE(true);
}