Commit 373c0ea1 authored by Haggai Eran's avatar Haggai Eran Committed by Roland Dreier

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: default avatarHaggai Eran <haggaie@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 8ec0a0e6
...@@ -534,7 +534,7 @@ static int add_port(struct ib_device *device, int port_num, ...@@ -534,7 +534,7 @@ static int add_port(struct ib_device *device, int port_num,
p->port_num = port_num; p->port_num = port_num;
ret = kobject_init_and_add(&p->kobj, &port_type, ret = kobject_init_and_add(&p->kobj, &port_type,
kobject_get(device->ports_parent), device->ports_parent,
"%d", port_num); "%d", port_num);
if (ret) if (ret)
goto err_put; goto err_put;
...@@ -599,7 +599,6 @@ static int add_port(struct ib_device *device, int port_num, ...@@ -599,7 +599,6 @@ static int add_port(struct ib_device *device, int port_num,
sysfs_remove_group(&p->kobj, &pma_group); sysfs_remove_group(&p->kobj, &pma_group);
err_put: err_put:
kobject_put(device->ports_parent);
kfree(p); kfree(p);
return ret; return ret;
} }
...@@ -835,7 +834,7 @@ int ib_device_register_sysfs(struct ib_device *device, ...@@ -835,7 +834,7 @@ int ib_device_register_sysfs(struct ib_device *device,
} }
device->ports_parent = kobject_create_and_add("ports", device->ports_parent = kobject_create_and_add("ports",
kobject_get(&class_dev->kobj)); &class_dev->kobj);
if (!device->ports_parent) { if (!device->ports_parent) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_put; goto err_put;
...@@ -876,8 +875,6 @@ int ib_device_register_sysfs(struct ib_device *device, ...@@ -876,8 +875,6 @@ int ib_device_register_sysfs(struct ib_device *device,
} }
} }
kobject_put(&class_dev->kobj);
err_unregister: err_unregister:
device_unregister(class_dev); device_unregister(class_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment