summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSantosh Y <santosh.sy@samsung.com>2014-05-29 10:01:52 +0530
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2014-06-03 16:43:30 -0400
commit6808c5fb7fc1574c7608a38c9819f1639d89c3d0 (patch)
treeb87da5426b9a9e510b49e173532a3a9e50e27be1 /drivers
parent4131f2fcdc5853d995044d4ed995a25ee4eb5ab2 (diff)
NVMe: Prevent possible NULL pointer dereference
kmalloc() used by the nvme_alloc_iod() to allocate memory for 'iod' can fail. So check the return value. Signed-off-by: Santosh Y <santosh.sy@samsung.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/nvme-core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index b82155888845..872d8e42d008 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1488,7 +1488,11 @@ struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
goto put_pages;
}
+ err = -ENOMEM;
iod = nvme_alloc_iod(count, length, GFP_KERNEL);
+ if (!iod)
+ goto put_pages;
+
sg = iod->sg;
sg_init_table(sg, count);
for (i = 0; i < count; i++) {
@@ -1501,7 +1505,6 @@ struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
sg_mark_end(&sg[i - 1]);
iod->nents = count;
- err = -ENOMEM;
nents = dma_map_sg(&dev->pci_dev->dev, sg, count,
write ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (!nents)