Skip to contentSkip to conversation

nvme: fix uninitialized return of ret when sysfs_create_link fails

PATCH In review Colin King 2 participants 2 messages Oct 2, 2019 – Oct 5, 2019

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 nvme: fix uninitialized return of ret when sysfs_create_link fails

From: Colin Ian King <[email protected]>

Currently when the call to sysfs_create_link fails the error exit path returns an uninitialized value in variable ret. Fix this by returning the error code returned from the failed call to sysfs_create_link.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes 32fd90c40768 ("nvme: change locking for the per-subsystem controller list")
---
 drivers/nvme/host/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +3 -2
index 63b37d08ac98..f6acbff3e3bc 100644
@@ -2540,8 +2540,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 		list_add_tail(&subsys->entry, &nvme_subsystems);
 	}
 
-	if (sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj,
-			dev_name(ctrl->device))) {
+	ret = sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj,
+				dev_name(ctrl->device));
+	if (ret) {
 		dev_err(ctrl->device,
 			"failed to create sysfs link from subsystem.\n");
 		goto out_put_subsystem;
Signature · 1 line
2.20.1
maintainer
#1 lore raw

This was already fixed and merged (by Dan)

Quoted 31 lines · Colin King

From: Colin Ian King <[email protected]>

Currently when the call to sysfs_create_link fails the error exit path returns an uninitialized value in variable ret. Fix this by returning the error code returned from the failed call to sysfs_create_link.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes 32fd90c40768 ("nvme: change locking for the per-subsystem controller list")
---
  drivers/nvme/host/core.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +3 -2
index 63b37d08ac98..f6acbff3e3bc 100644
@@ -2540,8 +2540,9 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
  		list_add_tail(&subsys->entry, &nvme_subsystems);
  	}
 
-	if (sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj,
-			dev_name(ctrl->device))) {
+	ret = sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj,
+				dev_name(ctrl->device));
+	if (ret) {
  		dev_err(ctrl->device,
  			"failed to create sysfs link from subsystem.\n");
  		goto out_put_subsystem;