summaryrefslogtreecommitdiff
path: root/drivers/block/nvme.c
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2012-08-03 00:05:59 +0400
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2012-11-13 18:13:49 +0400
commit859361a228258edf4821d9f5635825033eca78e8 (patch)
tree8c6f6c5344b163ed3d3fa479858d840a4209da32 /drivers/block/nvme.c
parent9924a1992a86ebdb7ca36ef790d2ba0da506296c (diff)
downloadlinux-859361a228258edf4821d9f5635825033eca78e8.tar.xz
NVMe: Free cmdid on nvme_submit_bio error
nvme_map_bio() is called after the cmdid is allocated, so we have to free the cmdid before returning from nvme_submit_bio() if nvme_map_bio() returned an error. Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Diffstat (limited to 'drivers/block/nvme.c')
-rw-r--r--drivers/block/nvme.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/block/nvme.c b/drivers/block/nvme.c
index 931769e133e5..954a61018dc2 100644
--- a/drivers/block/nvme.c
+++ b/drivers/block/nvme.c
@@ -237,7 +237,8 @@ static void *free_cmdid(struct nvme_queue *nvmeq, int cmdid,
*fn = special_completion;
return CMD_CTX_INVALID;
}
- *fn = info[cmdid].fn;
+ if (fn)
+ *fn = info[cmdid].fn;
ctx = info[cmdid].ctx;
info[cmdid].fn = special_completion;
info[cmdid].ctx = CMD_CTX_COMPLETED;
@@ -589,7 +590,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
result = nvme_map_bio(nvmeq->q_dmadev, iod, bio, dma_dir, psegs);
if (result < 0)
- goto free_iod;
+ goto free_cmdid;
length = result;
cmnd->rw.command_id = cmdid;
@@ -609,6 +610,8 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
return 0;
+ free_cmdid:
+ free_cmdid(nvmeq, cmdid, NULL);
free_iod:
nvme_free_iod(nvmeq->dev, iod);
nomem: