All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme: fix uninitialized prp2 value on small transfers
@ 2017-08-27 13:56 Jan H. Schönherr
  2017-08-27 16:00 ` Christoph Hellwig
       [not found] ` <CADL4p-oxDfu0srX90+u9d0HfXLCNpFk2NdcoeaWEmMjRnwHX2w@mail.gmail.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Jan H. Schönherr @ 2017-08-27 13:56 UTC (permalink / raw)


The value of iod->first_dma ends up as prp2 in NVMe commands. In case
there is not enough data to cross a page boundary, iod->first_dma is
never initialized and contains random data.

Comply with the NVMe specification and fill in 0 in that case.

Signed-off-by: Jan H. Sch?nherr <jschoenh at amazon.de>
---
 drivers/nvme/host/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 925467b..4a41a65 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -555,8 +555,10 @@ static blk_status_t nvme_setup_prps(struct nvme_dev *dev, struct request *req)
 	int nprps, i;
 
 	length -= (page_size - offset);
-	if (length <= 0)
+	if (length <= 0) {
+		iod->first_dma = 0;
 		return BLK_STS_OK;
+	}
 
 	dma_len -= (page_size - offset);
 	if (dma_len) {
-- 
2.3.1.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-28  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-27 13:56 [PATCH] nvme: fix uninitialized prp2 value on small transfers Jan H. Schönherr
2017-08-27 16:00 ` Christoph Hellwig
2017-08-27 16:56   ` Jan H. Schönherr
     [not found] ` <CADL4p-oxDfu0srX90+u9d0HfXLCNpFk2NdcoeaWEmMjRnwHX2w@mail.gmail.com>
2017-08-28  7:41   ` Sagi Grimberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.