From: Lei Rao Date: Tue, 29 Nov 2022 09:48:11 +0000 (+0800) Subject: nvme-pci: clear the prp2 field when not used X-Git-Tag: v6.1-rc8~9^2^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a56ea6147facce4ac1fc38675455f9733d96232b;p=users%2Fdwmw2%2Flinux.git nvme-pci: clear the prp2 field when not used If the prp2 field is not filled in nvme_setup_prp_simple(), the prp2 field is garbage data. According to nvme spec, the prp2 is reserved if the data transfer does not cross a memory page boundary, so clear it to zero if it is not used. Signed-off-by: Lei Rao Signed-off-by: Christoph Hellwig --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index f4335519399d0..488ad7dabeb8e 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -797,6 +797,8 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev *dev, cmnd->dptr.prp1 = cpu_to_le64(iod->first_dma); if (bv->bv_len > first_prp_len) cmnd->dptr.prp2 = cpu_to_le64(iod->first_dma + first_prp_len); + else + cmnd->dptr.prp2 = 0; return BLK_STS_OK; }