IB/qib: Correct qib_verbs_register_sysfs() error handling
PATCH v2 1/1 IB/qib: Correct qib_verbs_register_sysfs() error handling
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 <[email protected]>
Reviewed-by Dean Luick <[email protected]>
Signed-off-by Mike Marciniszyn <[email protected]>
--- drivers/infiniband/hw/qib/qib_sysfs.c | 6 +++++- drivers/infiniband/hw/qib/qib_verbs.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/hw/qib/qib_sysfs.c +5 -1
@@ -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; }/*
drivers/infiniband/hw/qib/qib_verbs.c +2 -1
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html