Commit 137200a4 authored by Mike Marciniszyn's avatar Mike Marciniszyn Committed by Roland Dreier

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: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Reviewed-by: default avatarDean Luick <dean.luick@intel.com>
Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 41ef2d56
...@@ -2187,7 +2187,8 @@ int ipath_register_ib_device(struct ipath_devdata *dd) ...@@ -2187,7 +2187,8 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
if (ret) if (ret)
goto err_reg; goto err_reg;
if (ipath_verbs_register_sysfs(dev)) ret = ipath_verbs_register_sysfs(dev);
if (ret)
goto err_class; goto err_class;
enable_timer(dd); enable_timer(dd);
...@@ -2327,15 +2328,15 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev) ...@@ -2327,15 +2328,15 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev)
int i; int i;
int ret; int ret;
for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) {
if (device_create_file(&dev->dev, ret = device_create_file(&dev->dev,
ipath_class_attributes[i])) { ipath_class_attributes[i]);
ret = 1; if (ret)
goto bail; goto bail;
} }
return 0;
ret = 0;
bail: bail:
for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
device_remove_file(&dev->dev, ipath_class_attributes[i]);
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment