Skip to content

Commit

Permalink
IB/ipath: Correct ipath_verbs_register_sysfs() error handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Marciniszyn authored and Roland Dreier committed Apr 17, 2013
1 parent 41ef2d5 commit 137200a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/infiniband/hw/ipath/ipath_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

0 comments on commit 137200a

Please sign in to comment.