IB/qib: Correct qib_verbs_register_sysfs() error handling
[cascardo/linux.git] / drivers / infiniband / hw / qib / qib_sysfs.c
index 034cc82..3c8e4e3 100644 (file)
@@ -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;
 }
 
 /*