Skip to content

Commit

Permalink
nvme: fix uninitialized prp2 value on small transfers
Browse files Browse the repository at this point in the history
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@amazon.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Jan H. Schönherr authored and Sagi Grimberg committed Aug 28, 2017
1 parent a7b7c7a commit 5228b32
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/nvme/host/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5228b32

Please sign in to comment.