Skip to contentSkip to conversation

IB/qib: Correct ipath_verbs_register_sysfs() error handling

PATCH Superseded Mike Marciniszyn 1 participant 2 messages Mar 28, 2013 1 message not in the archive InfiniBand

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 IB/qib: Correct ipath_verbs_register_sysfs() error handling

qib_verbs_register_sysfs() never cleanup up from a failure. Additionally, the caller of qib_verbs_register_sysfs() doesn't return the correct "ret" value.

This patch resolves both of those issues.

---
 drivers/infiniband/hw/qib/qib_sysfs.c |    6 +++++-
 drivers/infiniband/hw/qib/qib_verbs.c |    3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/hw/qib/qib_sysfs.c +5 -1
index 034cc82..3c8e4e3 100644
@@ -808,10 +808,14 @@ int qib_verbs_register_sysfs(struct qib_devdata *dd)
 	for (i = 0; i < ARRAY_SIZE(qib_attributes); ++i) {
 		ret = device_create_file(&dev->dev, qib_attributes[i]);
 		if (ret)
-			return ret;
+			goto bail;
 	}
 
 	return 0;
+bail:
+	for (i = 0; i < ARRAY_SIZE(qib_attributes); ++i)
+		device_remove_file(&dev->dev, qib_attributes[i]);
+	return ret;
 }
 
 /*
drivers/infiniband/hw/qib/qib_verbs.c +2 -1
index 7c0ab16..904c384 100644
@@ -2234,7 +2234,8 @@ int qib_register_ib_device(struct qib_devdata *dd)
 	if (ret)
 		goto err_agents;
 
-	if (qib_verbs_register_sysfs(dd))
+	ret = qib_verbs_register_sysfs(dd);
+	if (ret)
 		goto err_class;
 
 	goto bail;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

PATCH 2/2 IB/ipath: Correct ipath_verbs_register_sysfs() error handling

In reply to a message not in the archive

ipath_verbs_register_sysfs() never returned the correct error code from device_create_file and never cleanup up from a failure. Additionally, the caller of ipath_verbs_register_sysfs() doesn't return the correct "ret" value.

This patch resolves all of these issues.

---
 drivers/infiniband/hw/ipath/ipath_verbs.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
drivers/infiniband/hw/ipath/ipath_verbs.c +10 -9
index ea93870..44ea939 100644
@@ -2187,7 +2187,8 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
 	if (ret)
 		goto err_reg;
 
-	if (ipath_verbs_register_sysfs(dev))
+	ret = ipath_verbs_register_sysfs(dev);
+	if (ret)
 		goto err_class;
 
 	enable_timer(dd);
@@ -2327,15 +2328,15 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev)
 	int i;
 	int ret;
 
-	for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
-		if (device_create_file(&dev->dev,
-				       ipath_class_attributes[i])) {
-			ret = 1;
+	for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) {
+		ret = device_create_file(&dev->dev,
+				       ipath_class_attributes[i]);
+		if (ret)
 			goto bail;
-		}
-
-	ret = 0;
-
+	}
+	return 0;
 bail:
+	for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
+		device_remove_file(&dev->dev, ipath_class_attributes[i]);
 	return ret;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html