[Patch -mm] kobject: kobject_add() reference leak

From: Cornelia Huck
Date: Tue Apr 10 2007 - 08:33:25 EST


<This patch is the "pathological case" in the referenced mail.>

We leak a reference if we attempt to add a kobject with no name.

Signed-off-by: Cornelia Huck <cornelia.huck@xxxxxxxxxx>

---
lib/kobject.c | 1 +
1 files changed, 1 insertion(+)

--- linux-2.6.21-rc6-mm1.orig/lib/kobject.c
+++ linux-2.6.21-rc6-mm1/lib/kobject.c
@@ -218,6 +218,7 @@ int kobject_shadow_add(struct kobject *
if (!*kobj->k_name) {
pr_debug("kobject attempted to be registered with no name!\n");
WARN_ON(1);
+ kobject_put(kobj);
return -EINVAL;
}
parent = kobject_get(kobj->parent);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/