Skip to contentSkip to conversation

scsi: ufs: Fix divide zero case in ufshcd_map_queues()

PATCH Applied Jinyoung CHOI 3 participants 4 messages Feb 14, 2022 – Feb 15, 2022 1 message not in the archive SCSI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20220214103352epcms2p79697c0fcaa2755dd89af9de887ff14cd@epcms2p7

#1 lore raw

PATCH 1/1 scsi: ufs: Fix divide zero case in ufshcd_map_queues()

Before calling blk_mq_map_queues(), the mq_map and nr_queues belonging to "struct blk_mq_queue_map" must be a vaild value.

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

    blk_mq_map_queues() -> queue_index()
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
index 41d85b69fa50..36c5ca62ae0c 100644
@@ -2674,21 +2674,21 @@ static int ufshcd_map_queues(struct Scsi_Host *shost)
 	for (i = 0; i < shost->nr_maps; i++) {
 		struct blk_mq_queue_map *map = &shost->tag_set.map[i];
 
 		switch (i) {
 		case HCTX_TYPE_DEFAULT:
 		case HCTX_TYPE_POLL:
 			map->nr_queues = 1;
 			break;
 		case HCTX_TYPE_READ:
 			map->nr_queues = 0;
-			break;
+			continue;
 		default:
 			WARN_ON_ONCE(true);
 		}
 		map->queue_offset = 0;
 		ret = blk_mq_map_queues(map);
 		WARN_ON_ONCE(ret);
 	}
 
 	return 0;
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#2 lore raw
Quoted 2 lines · Jinyoung CHOI

Before calling blk_mq_map_queues(), the mq_map and nr_queues belonging to "struct blk_mq_queue_map" must be a vaild value.

                                    ^^   ^^^^^
                                  have   valid
Quoted 2 lines

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

Anyway:

#3 lore raw

RE:(2) [PATCH] scsi: ufs: Fix divide zero case in ufshcd_map_queues()

Quoted 6 lines
Quoted 2 lines · Jinyoung CHOI

 Before calling blk_mq_map_queues(), the mq_map and nr_queues belonging to "struct blk_mq_queue_map" must be a vaild value.

                                     ^^   ^^^^^
                                   have   valid

Quoted 6 lines
Quoted 2 lines

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


Anyway:

Hi, Bart.

Thanks for your review.
I will be careful of typo. :)

Best Regards,
Jinyoung Choi

#4 lore raw
In reply to Jinyoung CHOI
Quoted 9 lines · Jinyoung CHOI

Before calling blk_mq_map_queues(), the mq_map and nr_queues belonging to "struct blk_mq_queue_map" must be a vaild value.

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

    blk_mq_map_queues() -> queue_index()

[...]

Applied to 5.17/scsi-fixes, thanks!

[1/1] scsi: ufs: Fix divide zero case in ufshcd_map_queues()

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