Skip to contentSkip to conversation

fix return value in ib_device_register_sysfs()

PATCH In review Li Zefan 2 participants 3 messages Feb 15, 2008 InfiniBand

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 1/1 fix return value in ib_device_register_sysfs()

Set ret to -ENOMEM when kobject_create_and_add() returns NULL.

---
 drivers/infiniband/core/sysfs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/infiniband/core/sysfs.c +3 -1
index c864ef7..5a4b2e6 100644
@@ -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);
Signature · 1 line
1.5.4.rc3
#1 lore raw

Wow, good catch. How did you find this bug?

Anyway, thanks, applied.

- R.

author
#2 lore raw
Quoted 2 lines · Roland Dreier

Wow, good catch. How did you find this bug?

Just by accident, when I glanced down the code. ;)

Quoted 4 lines

Anyway, thanks, applied.

- R.