From: Li Zefan Date: Fri, 15 Feb 2008 02:24:49 +0000 (+0800) Subject: IB: Fix return value in ib_device_register_sysfs() X-Git-Tag: v2.6.25-rc3~130^2~3 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=c7482b81c8b524193d736488c149adbe27a7eb7f;p=linux-2.6-omap-h63xx.git 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: Li Zefan Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index c864ef70fdf..5a4b2e65534 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -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);