summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2015-06-20 16:29:14 +0800
committerJens Axboe <axboe@fb.com>2015-06-20 10:34:07 -0600
commit51ef72bda70841fddd595142ed0e7e0fc571c500 (patch)
tree77ba038f4cac07d04b0de9e4c445839418687a86 /drivers/block
parent71feb364e7faadc681e714f7fdc2bede208ba26c (diff)
downloadlinux-51ef72bda70841fddd595142ed0e7e0fc571c500.tar.bz2
block: nvme-scsi: Catch kcalloc failure
res variable was initialized to -ENOMEM, but it's override by nvme_trans_copy_from_user(). So current code returns 0 if kcalloc fails. Fix it to return proper error code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nvme-scsi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index 8e6223e5b670..ab6d1a0e5167 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -2375,7 +2375,7 @@ static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr,
struct scsi_unmap_parm_list *plist;
struct nvme_dsm_range *range;
struct nvme_command c;
- int i, nvme_sc, res = -ENOMEM;
+ int i, nvme_sc, res;
u16 ndesc, list_len;
list_len = get_unaligned_be16(&cmd[7]);
@@ -2397,8 +2397,10 @@ static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr,
}
range = kcalloc(ndesc, sizeof(*range), GFP_KERNEL);
- if (!range)
+ if (!range) {
+ res = -ENOMEM;
goto out;
+ }
for (i = 0; i < ndesc; i++) {
range[i].nlb = cpu_to_le32(be32_to_cpu(plist->desc[i].nlb));