summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Pravin <francis.p@samsung.com>2025-01-10 02:51:37 +0300
committerKeith Busch <kbusch@kernel.org>2025-01-13 01:11:29 +0300
commit4a324970fabad503260973cd588609f3a26baab9 (patch)
tree5f8d27bafdc4ad72f8e5747efe37c5c9a91b635d
parentd4a95adeabc6b5a39405e49c6d5ed14dd83682c4 (diff)
downloadlinux-4a324970fabad503260973cd588609f3a26baab9.tar.xz
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>
-rw-r--r--drivers/nvme/host/pci.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index c3bfbe11ee57..fe0795e16e25 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2085,8 +2085,8 @@ static int nvme_alloc_host_mem_single(struct nvme_dev *dev, u64 size)
sizeof(*dev->host_mem_descs), &dev->host_mem_descs_dma,
GFP_KERNEL);
if (!dev->host_mem_descs) {
- dma_free_noncontiguous(dev->dev, dev->host_mem_size,
- dev->hmb_sgt, DMA_BIDIRECTIONAL);
+ dma_free_noncontiguous(dev->dev, size, dev->hmb_sgt,
+ DMA_BIDIRECTIONAL);
dev->hmb_sgt = NULL;
return -ENOMEM;
}