From: Leon Romanovsky Date: Wed, 24 Jul 2024 10:31:14 +0000 (+0300) Subject: nvme-pci: add missing condition check for existence of mapped data X-Git-Tag: v6.11-rc1~9^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c31fad1470389666ac7169fe43aa65bf5b7e2cfd;p=thirdparty%2Fkernel%2Flinux.git 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: 4aedb705437f ("nvme-pci: split metadata handling from nvme_map_data / nvme_unmap_data") Signed-off-by: Leon Romanovsky Reviewed-by: Christoph Hellwig Reviewed-by: Nitesh Shetty Signed-off-by: Keith Busch --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 8087b054da668..6cd9395ba9ec3 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -863,7 +863,8 @@ static blk_status_t nvme_prep_rq(struct nvme_dev *dev, struct request *req) nvme_start_request(req); return BLK_STS_OK; out_unmap_data: - nvme_unmap_data(dev, req); + if (blk_rq_nr_phys_segments(req)) + nvme_unmap_data(dev, req); out_free_cmd: nvme_cleanup_cmd(req); return ret;