Commit 51ef72bd authored by Axel Lin's avatar Axel Lin Committed by Jens Axboe

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: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 71feb364
...@@ -2375,7 +2375,7 @@ static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr, ...@@ -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 scsi_unmap_parm_list *plist;
struct nvme_dsm_range *range; struct nvme_dsm_range *range;
struct nvme_command c; struct nvme_command c;
int i, nvme_sc, res = -ENOMEM; int i, nvme_sc, res;
u16 ndesc, list_len; u16 ndesc, list_len;
list_len = get_unaligned_be16(&cmd[7]); 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, ...@@ -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); range = kcalloc(ndesc, sizeof(*range), GFP_KERNEL);
if (!range) if (!range) {
res = -ENOMEM;
goto out; goto out;
}
for (i = 0; i < ndesc; i++) { for (i = 0; i < ndesc; i++) {
range[i].nlb = cpu_to_le32(be32_to_cpu(plist->desc[i].nlb)); range[i].nlb = cpu_to_le32(be32_to_cpu(plist->desc[i].nlb));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment