linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] NVMe: handle allocation failure in nvme_map_user_pages()
@ 2012-01-20  7:55 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2012-01-20  7:55 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-kernel, kernel-janitors

We should return here and avoid a NULL dereference.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index f4996b0..d826726 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -1042,6 +1042,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) {

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-01-20  7:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-20  7:55 [patch] NVMe: handle allocation failure in nvme_map_user_pages() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).