From: Keith Busch Date: Wed, 18 Nov 2015 23:33:08 +0000 (-0700) Subject: NVMe: Fix possible arithmetic overflow for max segments X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6824c5ef5e8900e61ce8ed40885cacc1c9301c14;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git NVMe: Fix possible arithmetic overflow for max segments Reported-by: Paul Grabinar Signed-off-by: Keith Busch Signed-off-by: Jens Axboe --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 8187df204695..394fd1631cd0 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2268,7 +2268,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);