]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
NVMe: Fix possible arithmetic overflow for max segments
authorKeith Busch <keith.busch@intel.com>
Wed, 18 Nov 2015 23:33:08 +0000 (16:33 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 6 Jul 2016 23:32:05 +0000 (16:32 -0700)
Reported-by: Paul Grabinar <paul.grabinar@ranbarg.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 6824c5ef5e8900e61ce8ed40885cacc1c9301c14)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
drivers/nvme/host/pci.c

index dacdd0fa2d82c7bd40dd520b381108f4b974439f..0ac79280bc4325c4fc3789562b263a67a93510fd 100644 (file)
@@ -2148,7 +2148,7 @@ static void nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid)
        if (dev->max_hw_sectors) {
                blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors);
                blk_queue_max_segments(ns->queue,
-                       ((dev->max_hw_sectors << 9) / dev->page_size) + 1);
+                       (dev->max_hw_sectors / (dev->page_size >> 9)) + 1);
        }
        if (dev->stripe_size)
                blk_queue_chunk_sectors(ns->queue, dev->stripe_size >> 9);