Skip to content

Commit

Permalink
NVMe: handle allocation failure in nvme_map_user_pages()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Matthew Wilcox committed Jul 31, 2012
1 parent c7d36ab commit 22fff82
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/block/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 22fff82

Please sign in to comment.