Skip to content

Commit c31fad1

Browse files
rleonkeithbusch
authored andcommitted
nvme-pci: add missing condition check for existence of mapped data
nvme_map_data() is called when request has physical segments, hence the nvme_unmap_data() should have same condition to avoid dereference. Fixes: 4aedb70 ("nvme-pci: split metadata handling from nvme_map_data / nvme_unmap_data") Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Nitesh Shetty <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 415fb38 commit c31fad1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ static blk_status_t nvme_prep_rq(struct nvme_dev *dev, struct request *req)
863863
nvme_start_request(req);
864864
return BLK_STS_OK;
865865
out_unmap_data:
866-
nvme_unmap_data(dev, req);
866+
if (blk_rq_nr_phys_segments(req))
867+
nvme_unmap_data(dev, req);
867868
out_free_cmd:
868869
nvme_cleanup_cmd(req);
869870
return ret;

0 commit comments

Comments
 (0)