[PATCH] NVMe: check the return of nvme_alloc_iod

From: Yuanhan Liu
Date: Thu Oct 18 2012 - 06:43:04 EST


It maybe failed due to out of memory.

Cc: Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>
Cc: Keith Busch <keith.busch@xxxxxxxxx>
Signed-off-by: Yuanhan Liu <yuanhan.liu@xxxxxxxxxxxxxxx>
---
drivers/block/nvme.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 931769e..eb58978 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -1091,6 +1091,10 @@ static struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
}

iod = nvme_alloc_iod(count, length, GFP_KERNEL);
+ if (!iod) {
+ err = -ENOMEM;
+ goto put_pages;
+ }
sg = iod->sg;
sg_init_table(sg, count);
for (i = 0; i < count; i++) {
--
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/