Skip to content

Commit

Permalink
NVMe: Fix divide-by-zero in nvme_trans_io_get_num_cmds
Browse files Browse the repository at this point in the history
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 <mundu2510@gmail.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
  • Loading branch information
Keith Busch authored and Matthew Wilcox committed Mar 24, 2014
1 parent 4f5099a commit ddcb776
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/block/nvme-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ddcb776

Please sign in to comment.