From: Keith Busch Date: Wed, 18 Nov 2015 23:33:08 +0000 (-0700) Subject: NVMe: Fix possible arithmetic overflow for max segments X-Git-Tag: v4.1.12-92~126^2~221 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4851814ebcb289719bcb314bbd76de0df5e00544;p=users%2Fjedix%2Flinux-maple.git NVMe: Fix possible arithmetic overflow for max segments Reported-by: Paul Grabinar Signed-off-by: Keith Busch Signed-off-by: Jens Axboe (cherry picked from commit 6824c5ef5e8900e61ce8ed40885cacc1c9301c14) Orabug: 22620486 Signed-off-by: Jason Luo --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index dacdd0fa2d82c..0ac79280bc432 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -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);