[PATCH 01/14] nvme-core: remove duplicate kfree in init identify

Chaitanya Kulkarni chaitanya.kulkarni at wdc.com
Tue Feb 16 19:10:19 EST 2021


In nvme_init_identify() once we initialize nvme_mpath_init() we free
the id with kfree(). This is needed since we just return from all the
following calls to nvme_mpath_init(), that also makes kfree() call
duplicate.

Instead of returning after nvme_mpath_init() jump to the lable
out_free and remove the duplicate call to the kfree() since out_free
label already has one..

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 drivers/nvme/host/core.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d77f3f26d8d3..70042e111efe 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3209,10 +3209,8 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 	}
 
 	ret = nvme_mpath_init(ctrl, id);
-	kfree(id);
-
 	if (ret < 0)
-		return ret;
+		goto out_free;
 
 	if (ctrl->apst_enabled && !prev_apst_enabled)
 		dev_pm_qos_expose_latency_tolerance(ctrl->device);
@@ -3221,29 +3219,29 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 
 	ret = nvme_configure_apst(ctrl);
 	if (ret < 0)
-		return ret;
+		goto out_free;
 	
 	ret = nvme_configure_timestamp(ctrl);
 	if (ret < 0)
-		return ret;
+		goto out_free;
 
 	ret = nvme_configure_directives(ctrl);
 	if (ret < 0)
-		return ret;
+		goto out_free;
 
 	ret = nvme_configure_acre(ctrl);
 	if (ret < 0)
-		return ret;
+		goto out_free;
 
 	if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) {
 		ret = nvme_hwmon_init(ctrl);
 		if (ret < 0)
-			return ret;
+			goto out_free;
 	}
 
 	ctrl->identified = true;
 
-	return 0;
+	ret = 0;
 
 out_free:
 	kfree(id);
-- 
2.22.1




More information about the Linux-nvme mailing list