nvme-pci: check for NULL return from pci_alloc_p2pmem()
authorAlan Mikhak <alan.mikhak@sifive.com>
Mon, 8 Jul 2019 17:05:11 +0000 (10:05 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 9 Jul 2019 20:44:44 +0000 (13:44 -0700)
commitbfac8e9f55cf62a000b643a0081488badbe92d96
tree6392321a958f24de93702807cba2a541d0e9a7ac
parent0298d5435276e7795b0b939d74827f6e775e7009
nvme-pci: check for NULL return from pci_alloc_p2pmem()

Modify nvme_alloc_sq_cmds() to call pci_free_p2pmem() to free the memory
it allocated using pci_alloc_p2pmem() in case pci_p2pmem_virt_to_bus()
returns null.

Makes sure not to call pci_free_p2pmem() if pci_alloc_p2pmem() returned
NULL, which can happen if CONFIG_PCI_P2PDMA is not configured.

The current implementation is not expected to leak since
pci_p2pmem_virt_to_bus() is expected to fail only if pci_alloc_p2pmem()
returns null. However, checking the return value of pci_alloc_p2pmem()
is more explicit.

Signed-off-by: Alan Mikhak <alan.mikhak@sifive.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/pci.c