]> Pileus Git - ~andy/linux/commitdiff
NVMe: handle allocation failure in nvme_map_user_pages()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 20 Jan 2012 12:55:30 +0000 (07:55 -0500)
committerMatthew Wilcox <matthew.r.wilcox@intel.com>
Tue, 31 Jul 2012 17:15:43 +0000 (13:15 -0400)
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>
drivers/block/nvme.c

index 6c0eb768562f25c53106cc3e14d928e8eab9a971..064e86a6bb4e429a2d0c0804155a38a9678f5c22 100644 (file)
@@ -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) {