aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinwoo Im <minwoo.im.dev@gmail.com>2017-11-24 13:03:00 -0500
committerChristoph Hellwig <hch@lst.de>2017-11-28 11:49:26 -0500
commit7e5dd57ef3081ff6c03908d786ed5087f6fbb7ae (patch)
tree96909503a6a4b6a07c95daf553f27737532c8046
parenteb1bd249ba016284ed762d87c1989dd822500773 (diff)
nvme-pci: fix NULL pointer dereference in nvme_free_host_mem()
Following condition which will cause NULL pointer dereference will occur in nvme_free_host_mem() when it tries to remove pci device via nvme_remove() especially after a failure of host memory allocation for HMB. "(host_mem_descs == NULL) && (nr_host_mem_descs != 0)" It's because __nr_host_mem_descs__ is not cleared to 0 unlike __host_mem_descs__ is so. Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/nvme/host/pci.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 617374762b7c..f5800c3c9082 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1759,6 +1759,7 @@ static void nvme_free_host_mem(struct nvme_dev *dev)
1759 dev->nr_host_mem_descs * sizeof(*dev->host_mem_descs), 1759 dev->nr_host_mem_descs * sizeof(*dev->host_mem_descs),
1760 dev->host_mem_descs, dev->host_mem_descs_dma); 1760 dev->host_mem_descs, dev->host_mem_descs_dma);
1761 dev->host_mem_descs = NULL; 1761 dev->host_mem_descs = NULL;
1762 dev->nr_host_mem_descs = 0;
1762} 1763}
1763 1764
1764static int __nvme_alloc_host_mem(struct nvme_dev *dev, u64 preferred, 1765static int __nvme_alloc_host_mem(struct nvme_dev *dev, u64 preferred,