aboutsummaryrefslogtreecommitdiffstats
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)
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 6c0eb768562f..064e86a6bb4e 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,
1044 offset = offset_in_page(addr); 1044 offset = offset_in_page(addr);
1045 count = DIV_ROUND_UP(offset + length, PAGE_SIZE); 1045 count = DIV_ROUND_UP(offset + length, PAGE_SIZE);
1046 pages = kcalloc(count, sizeof(*pages), GFP_KERNEL); 1046 pages = kcalloc(count, sizeof(*pages), GFP_KERNEL);
1047 if (!pages)
1048 return ERR_PTR(-ENOMEM);
1047 1049
1048 err = get_user_pages_fast(addr, count, 1, pages); 1050 err = get_user_pages_fast(addr, count, 1, pages);
1049 if (err < count) { 1051 if (err < count) {