diff mbox series

Remove extra goto label from nvmet_ns_enable

Message ID 20180809110303.GA10167@machine1 (mailing list archive)
State Not Applicable
Headers show
Series Remove extra goto label from nvmet_ns_enable | expand

Commit Message

Milan P. Gandhi Aug. 9, 2018, 11:03 a.m. UTC
Currently nvmet_ns_enable has two labels viz. out_unlock and
out_dev_put, and the reverse call from out_dev_put to out_unlock
is little bit confusing. We could simplify it by calling
nvmet_ns_dev_disable before. This would eliminate need for
2nd out_dev_put label.

Also, this function already initializes ret variable to 0,
so there is no need to again initialize it to 0 before 
out_unlock, hence removing it.

Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
---
 drivers/nvme/target/core.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Johannes Thumshirn Aug. 9, 2018, 11:51 a.m. UTC | #1
please send this patch to the correct mailing list (linux-nvme@lists.infradead.org)
diff mbox series

Patch

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 9838103f2d62..b40fb6d724b4 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -346,9 +346,10 @@  int nvmet_ns_enable(struct nvmet_ns *ns)
 
 	ret = percpu_ref_init(&ns->ref, nvmet_destroy_namespace,
 				0, GFP_KERNEL);
-	if (ret)
-		goto out_dev_put;
-
+	if (ret) {
+		nvmet_ns_dev_disable(ns);
+		goto out_unlock;
+	}
 	if (ns->nsid > subsys->max_nsid)
 		subsys->max_nsid = ns->nsid;
 
@@ -372,13 +373,10 @@  int nvmet_ns_enable(struct nvmet_ns *ns)
 
 	nvmet_ns_changed(subsys, ns->nsid);
 	ns->enabled = true;
-	ret = 0;
+
 out_unlock:
 	mutex_unlock(&subsys->lock);
 	return ret;
-out_dev_put:
-	nvmet_ns_dev_disable(ns);
-	goto out_unlock;
 }
 
 void nvmet_ns_disable(struct nvmet_ns *ns)