summaryrefslogtreecommitdiffstats
path: root/drivers/nvme/target/core.c
diff options
context:
space:
mode:
authorSagi Grimberg <sagi@grimberg.me>2018-01-14 18:34:22 +0200
committerChristoph Hellwig <hch@lst.de>2018-01-15 17:09:32 +0100
commit423b4487fb23cc9bcbf14f748915bff46151506a (patch)
tree6e3e3f3451c52fff9bcfeb405d7e5141e7286431 /drivers/nvme/target/core.c
parentdf351ef73789345b4b6c00434c5fd1fca7175643 (diff)
downloadlinux-stable-423b4487fb23cc9bcbf14f748915bff46151506a.tar.gz
linux-stable-423b4487fb23cc9bcbf14f748915bff46151506a.tar.bz2
linux-stable-423b4487fb23cc9bcbf14f748915bff46151506a.zip
nvmet: release a ns reference in nvmet_req_uninit if needed
nvmet_req_init looked up a namespace and took a reference on it (unless it failed prior to that). If the request is uninitialized (in error cases) we need to remove that reference in case it was taken, otherwise we leak namespace reference when calling nvme_req_uninit. Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target/core.c')
-rw-r--r--drivers/nvme/target/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 7282ea8d3b96..0bd737117a80 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -512,6 +512,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
req->sg_cnt = 0;
req->transfer_len = 0;
req->rsp->status = 0;
+ req->ns = NULL;
/* no support for fused commands yet */
if (unlikely(flags & (NVME_CMD_FUSE_FIRST | NVME_CMD_FUSE_SECOND))) {
@@ -557,6 +558,8 @@ EXPORT_SYMBOL_GPL(nvmet_req_init);
void nvmet_req_uninit(struct nvmet_req *req)
{
percpu_ref_put(&req->sq->ref);
+ if (req->ns)
+ nvmet_put_namespace(req->ns);
}
EXPORT_SYMBOL_GPL(nvmet_req_uninit);