summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-01-20 07:55:30 -0500
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2012-07-31 13:15:43 -0400
commit22fff826e715e9727d3c7a69f15e602a9801b673 (patch)
treeb7c317cb56682e691c8c22423b81a15530e77421
parentc7d36ab8fa04c213328119a9c0d66985fe204ee5 (diff)
downloadop-kernel-dev-22fff826e715e9727d3c7a69f15e602a9801b673.zip
op-kernel-dev-22fff826e715e9727d3c7a69f15e602a9801b673.tar.gz
NVMe: handle allocation failure in nvme_map_user_pages()
We should return here and avoid a NULL dereference. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
-rw-r--r--drivers/block/nvme.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 6c0eb76..064e86a 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -1044,6 +1044,8 @@ static struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
offset = offset_in_page(addr);
count = DIV_ROUND_UP(offset + length, PAGE_SIZE);
pages = kcalloc(count, sizeof(*pages), GFP_KERNEL);
+ if (!pages)
+ return ERR_PTR(-ENOMEM);
err = get_user_pages_fast(addr, count, 1, pages);
if (err < count) {
OpenPOWER on IntegriCloud