summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorMike Marciniszyn <mike.marciniszyn@intel.com>2013-03-28 18:12:28 +0000
committerRoland Dreier <roland@purestorage.com>2013-04-16 23:04:36 -0700
commit137200a4bb74c6d3c13a8eea1edd617a15fdf3e2 (patch)
tree119b4e66aabea44c0ec38ea145093f153d1517a6 /drivers/infiniband
parent41ef2d5678d83af030125550329b6ae8b74618fa (diff)
downloadop-kernel-dev-137200a4bb74c6d3c13a8eea1edd617a15fdf3e2.zip
op-kernel-dev-137200a4bb74c6d3c13a8eea1edd617a15fdf3e2.tar.gz
IB/ipath: Correct ipath_verbs_register_sysfs() error handling
ipath_verbs_register_sysfs() never returned the correct error code from device_create_file and never cleaned 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. Reported-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Reviewed-by: Dean Luick <dean.luick@intel.com> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index ea93870..44ea939 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -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;
}
OpenPOWER on IntegriCloud