]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nvme-pci: fix freeing of the HMB descriptor table
authorChristoph Hellwig <hch@lst.de>
Fri, 1 Nov 2024 04:40:04 +0000 (05:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:47:43 +0000 (19:47 +0100)
commit452f9ddd12bebc04cef741e8ba3806bf0e1fd015
treeca3a046178e5e870ad507e56cb82aca9e8bca485
parentd3df9f26cff97beaa5643e551031795d5d5cddbe
nvme-pci: fix freeing of the HMB descriptor table

[ Upstream commit 3c2fb1ca8086eb139b2a551358137525ae8e0d7a ]

The HMB descriptor table is sized to the maximum number of descriptors
that could be used for a given device, but __nvme_alloc_host_mem could
break out of the loop earlier on memory allocation failure and end up
using less descriptors than planned for, which leads to an incorrect
size passed to dma_free_coherent.

In practice this was not showing up because the number of descriptors
tends to be low and the dma coherent allocator always allocates and
frees at least a page.

Fixes: 87ad72a59a38 ("nvme-pci: implement host memory buffer support")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/pci.c