[PATCH] block: add protection for divide by zero in blk_mq_map_queues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In function blk_mq_map_queues, qmap->nr_queues may equal zero
and thus it needs to be checked before we pass it to function
queue_index.

Signed-off-by: Yiyuan GUO <yguoaz@xxxxxxxxxx>
---
 block/blk-mq-cpumap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c
index 3db84d319..dc440870e 100644
--- a/block/blk-mq-cpumap.c
+++ b/block/blk-mq-cpumap.c
@@ -65,7 +65,8 @@ int blk_mq_map_queues(struct blk_mq_queue_map *qmap)
 		} else {
 			first_sibling = get_first_sibling(cpu);
 			if (first_sibling == cpu)
-				map[cpu] = queue_index(qmap, nr_queues, q++);
+				if (nr_queues)
+					map[cpu] = queue_index(qmap, nr_queues, q++);
 			else
 				map[cpu] = map[first_sibling];
 		}
-- 
2.25.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux