* [PATCH] block: nvme-scsi: Catch kcalloc failure
@ 2015-06-20 8:29 ` Axel Lin
0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2015-06-20 8:29 UTC (permalink / raw)
To: Matthew Wilcox, Jens Axboe; +Cc: linux-nvme, linux-kernel
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>
---
drivers/block/nvme-scsi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index a0fade9..e5a63f0 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -2377,7 +2377,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]);
@@ -2399,8 +2399,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));
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] block: nvme-scsi: Catch kcalloc failure
@ 2015-06-20 8:29 ` Axel Lin
0 siblings, 0 replies; 4+ messages in thread
From: Axel Lin @ 2015-06-20 8:29 UTC (permalink / raw)
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 at ingics.com>
---
drivers/block/nvme-scsi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index a0fade9..e5a63f0 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -2377,7 +2377,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]);
@@ -2399,8 +2399,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));
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: nvme-scsi: Catch kcalloc failure
2015-06-20 8:29 ` Axel Lin
@ 2015-06-20 16:33 ` Jens Axboe
-1 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2015-06-20 16:33 UTC (permalink / raw)
To: Axel Lin, Matthew Wilcox; +Cc: linux-nvme, linux-kernel
On 06/20/2015 02:29 AM, Axel Lin wrote:
> 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.
Looks good to me, applied for 4.2.
--
Jens Axboe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] block: nvme-scsi: Catch kcalloc failure
@ 2015-06-20 16:33 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2015-06-20 16:33 UTC (permalink / raw)
On 06/20/2015 02:29 AM, Axel Lin wrote:
> 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.
Looks good to me, applied for 4.2.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-20 16:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-20 8:29 [PATCH] block: nvme-scsi: Catch kcalloc failure Axel Lin
2015-06-20 8:29 ` Axel Lin
2015-06-20 16:33 ` Jens Axboe
2015-06-20 16:33 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.