IB/ipath: Correct ipath_verbs_register_sysfs() error handling
[linux.git] / drivers / infiniband / hw / ipath / ipath_verbs.c
index ea93870266eb7fda30ddf502b5d233fb1116423b..44ea9390417ceb0a572058ff9097be0d3871fe8e 100644 (file)
@@ -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;
 }