Commit c7482b81 authored by Li Zefan's avatar Li Zefan Committed by Roland Dreier

IB: Fix return value in ib_device_register_sysfs()

If kobject_create_and_add() fails and returns NULL, the current code
in ib_device_register_sysfs() does not set ret and hence returns 0.
Set ret to -ENOMEM for this failure, so that the caller knows that
ib_device_register_sysfs() actually failed.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 101142c3
......@@ -686,8 +686,10 @@ int ib_device_register_sysfs(struct ib_device *device)
device->ports_parent = kobject_create_and_add("ports",
kobject_get(&class_dev->kobj));
if (!device->ports_parent)
if (!device->ports_parent) {
ret = -ENOMEM;
goto err_put;
}
if (device->node_type == RDMA_NODE_IB_SWITCH) {
ret = add_port(device, 0);
......
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