]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
IB/qib: Correct qib_verbs_register_sysfs() error handling
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Thu, 28 Mar 2013 18:17:20 +0000 (18:17 +0000)
committerRoland Dreier <roland@purestorage.com>
Wed, 17 Apr 2013 06:04:36 +0000 (23:04 -0700)
qib_verbs_register_sysfs() never cleans up from a failure.
Additionally, the caller of qib_verbs_register_sysfs() doesn't
return the correct "ret" value.

This patch resolves both of those 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>
drivers/infiniband/hw/qib/qib_sysfs.c
drivers/infiniband/hw/qib/qib_verbs.c

index 034cc821de5ce9e5172046ee7b05f1fc822c5e88..3c8e4e3caca6240175bbddb35fb304107179920e 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;
 }
 
 /*
index 7c0ab16a2fe230fc31b44fd43b04f3e92d2a26b8..904c384aa36142b95455066cd6fcf80510b80959 100644 (file)
@@ -2234,7 +2234,8 @@ int qib_register_ib_device(struct qib_devdata *dd)
        if (ret)
                goto err_agents;
 
-       if (qib_verbs_register_sysfs(dd))
+       ret = qib_verbs_register_sysfs(dd);
+       if (ret)
                goto err_class;
 
        goto bail;