2012-10-18 10:43:15

by Yuanhan Liu

[permalink] [raw]
Subject: [PATCH] NVMe: check the return of nvme_alloc_iod

It maybe failed due to out of memory.

Cc: Matthew Wilcox <[email protected]>
Cc: Keith Busch <[email protected]>
Signed-off-by: Yuanhan Liu <[email protected]>
---
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