aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nvme.c
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2012-08-02 16:05:59 -0400
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2012-11-13 09:13:49 -0500
commit859361a228258edf4821d9f5635825033eca78e8 (patch)
tree8c6f6c5344b163ed3d3fa479858d840a4209da32 /drivers/block/nvme.c
parent9924a1992a86ebdb7ca36ef790d2ba0da506296c (diff)
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,
237 *fn = special_completion; 237 *fn = special_completion;
238 return CMD_CTX_INVALID; 238 return CMD_CTX_INVALID;
239 } 239 }
240 *fn = info[cmdid].fn; 240 if (fn)
241 *fn = info[cmdid].fn;
241 ctx = info[cmdid].ctx; 242 ctx = info[cmdid].ctx;
242 info[cmdid].fn = special_completion; 243 info[cmdid].fn = special_completion;
243 info[cmdid].ctx = CMD_CTX_COMPLETED; 244 info[cmdid].ctx = CMD_CTX_COMPLETED;
@@ -589,7 +590,7 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
589 590
590 result = nvme_map_bio(nvmeq->q_dmadev, iod, bio, dma_dir, psegs); 591 result = nvme_map_bio(nvmeq->q_dmadev, iod, bio, dma_dir, psegs);
591 if (result < 0) 592 if (result < 0)
592 goto free_iod; 593 goto free_cmdid;
593 length = result; 594 length = result;
594 595
595 cmnd->rw.command_id = cmdid; 596 cmnd->rw.command_id = cmdid;
@@ -609,6 +610,8 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns,
609 610
610 return 0; 611 return 0;
611 612
613 free_cmdid:
614 free_cmdid(nvmeq, cmdid, NULL);
612 free_iod: 615 free_iod:
613 nvme_free_iod(nvmeq->dev, iod); 616 nvme_free_iod(nvmeq->dev, iod);
614 nomem: 617 nomem: