Skip to content

Commit

Permalink
IB: Fix return value in ib_device_register_sysfs()
Browse files Browse the repository at this point in the history
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: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Li Zefan authored and Roland Dreier committed Feb 15, 2008
1 parent 101142c commit c7482b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/infiniband/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c7482b8

Please sign in to comment.