From ddcb776286c091189a7b928188112470ec7e9efc Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Mon, 24 Mar 2014 10:03:56 -0400 Subject: [PATCH] NVMe: Fix divide-by-zero in nvme_trans_io_get_num_cmds dev->max_hw_sectors may be zero to indicate the device has no limit on the number of sectors. nvme_trans_do_nvme_io() should use the software limit, since this is guaranteed to be non-zero. Reported-by: Mundu Signed-off-by: Keith Busch Signed-off-by: Matthew Wilcox --- drivers/block/nvme-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c index e157e85bb5d7..111c920c1574 100644 --- a/drivers/block/nvme-scsi.c +++ b/drivers/block/nvme-scsi.c @@ -2044,7 +2044,7 @@ static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, struct nvme_command c; u8 opcode = (is_write ? nvme_cmd_write : nvme_cmd_read); u16 control; - u32 max_blocks = nvme_block_nr(ns, dev->max_hw_sectors); + u32 max_blocks = queue_max_hw_sectors(ns->queue); num_cmds = nvme_trans_io_get_num_cmds(hdr, cdb_info, max_blocks); -- 2.30.2