diff options
author | Haggai Eran <haggaie@mellanox.com> | 2014-05-18 04:12:24 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2014-06-04 13:03:49 -0400 |
commit | 373c0ea181c8d277a4a51bbd705189a6a030b81c (patch) | |
tree | c6c9604c87f600788930250ac9aa397ca0864df7 | |
parent | 8ec0a0e6b58218bdc1db91dd70ebfcd6ad8dd6cd (diff) |
IB/core: Remove unneeded kobject_get/put calls
The ib_core module will call kobject_get on the parent object of each
kobject it creates. This is redundant since kobject_add does that
anyway.
As a side effect, this patch should fix leaking the ports kobject and
the device kobject during unregister flow, since the previous code
didn't seem to take into account the kobject_get calls on behalf of
the child kobjects.
Signed-off-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 7d3292c7b4b4..1f77072fa1fe 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -534,7 +534,7 @@ static int add_port(struct ib_device *device, int port_num, | |||
534 | p->port_num = port_num; | 534 | p->port_num = port_num; |
535 | 535 | ||
536 | ret = kobject_init_and_add(&p->kobj, &port_type, | 536 | ret = kobject_init_and_add(&p->kobj, &port_type, |
537 | kobject_get(device->ports_parent), | 537 | device->ports_parent, |
538 | "%d", port_num); | 538 | "%d", port_num); |
539 | if (ret) | 539 | if (ret) |
540 | goto err_put; | 540 | goto err_put; |
@@ -599,7 +599,6 @@ err_remove_pma: | |||
599 | sysfs_remove_group(&p->kobj, &pma_group); | 599 | sysfs_remove_group(&p->kobj, &pma_group); |
600 | 600 | ||
601 | err_put: | 601 | err_put: |
602 | kobject_put(device->ports_parent); | ||
603 | kfree(p); | 602 | kfree(p); |
604 | return ret; | 603 | return ret; |
605 | } | 604 | } |
@@ -835,7 +834,7 @@ int ib_device_register_sysfs(struct ib_device *device, | |||
835 | } | 834 | } |
836 | 835 | ||
837 | device->ports_parent = kobject_create_and_add("ports", | 836 | device->ports_parent = kobject_create_and_add("ports", |
838 | kobject_get(&class_dev->kobj)); | 837 | &class_dev->kobj); |
839 | if (!device->ports_parent) { | 838 | if (!device->ports_parent) { |
840 | ret = -ENOMEM; | 839 | ret = -ENOMEM; |
841 | goto err_put; | 840 | goto err_put; |
@@ -876,8 +875,6 @@ err_put: | |||
876 | } | 875 | } |
877 | } | 876 | } |
878 | 877 | ||
879 | kobject_put(&class_dev->kobj); | ||
880 | |||
881 | err_unregister: | 878 | err_unregister: |
882 | device_unregister(class_dev); | 879 | device_unregister(class_dev); |
883 | 880 | ||