Skip to content

Commit 4a32497

Browse files
francispravin5keithbusch
authored andcommitted
nvme-pci: use correct size to free the hmb buffer
dev->host_mem_size value is updated only after the successful buffer allocation of hmb descriptor. Otherwise, it may have some undefined value. So, use the correct size to free the hmb buffer when the hmb descriptor buffer allocation failed. Signed-off-by: Francis Pravin <francis.p@samsung.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent d4a95ad commit 4a32497

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/nvme/host/pci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,8 +2085,8 @@ static int nvme_alloc_host_mem_single(struct nvme_dev *dev, u64 size)
20852085
sizeof(*dev->host_mem_descs), &dev->host_mem_descs_dma,
20862086
GFP_KERNEL);
20872087
if (!dev->host_mem_descs) {
2088-
dma_free_noncontiguous(dev->dev, dev->host_mem_size,
2089-
dev->hmb_sgt, DMA_BIDIRECTIONAL);
2088+
dma_free_noncontiguous(dev->dev, size, dev->hmb_sgt,
2089+
DMA_BIDIRECTIONAL);
20902090
dev->hmb_sgt = NULL;
20912091
return -ENOMEM;
20922092
}

0 commit comments

Comments
 (0)