Skip to contentSkip to conversation

Fix possible kobject reference counter leak in kobject_rename()

PATCH In review Kenji Kaneshige 2 participants 3 messages Aug 21, 2008 – Aug 22, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix possible kobject reference counter leak in kobject_rename()

Hi,

I found a possible kobject reference counter leak problem in kobject_rename(). The following patch will fix it.

Thanks,
Kenji Kaneshige

Fix possible kobject reference counter leak in kobject_rename().

If kobject_rename() failed because of name collision, we must call kobject_put() for specified kobject before return.

---
 lib/kobject.c |    1 +
 1 file changed, 1 insertion(+)
lib/kobject.c +1 -0
Index: linux-2.6.27-rc4/lib/kobject.c
===================================================================
@@ -411,6 +411,7 @@ int kobject_rename(struct kobject *kobj,
 			       "to '%s' as '%s' is already in existence.\n",
 			       kobject_name(kobj), new_name, new_name);
 			kobject_put(temp_kobj);
+			kobject_put(kobj);
 			return -EINVAL;
 		}
 	}
#1 lore raw
Quoted 25 lines · Kenji Kaneshige

Hi,

I found a possible kobject reference counter leak problem in kobject_rename(). The following patch will fix it.

Thanks,
Kenji Kaneshige

Fix possible kobject reference counter leak in kobject_rename().

If kobject_rename() failed because of name collision, we must call kobject_put() for specified kobject before return.

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

Index: linux-2.6.27-rc4/lib/kobject.c
===================================================================

lib/kobject.c int kobject_rename(struct kobject *kobj, · line 417

Quoted 7 lines
lib/kobject.c +1 -0
@@ -411,6 +411,7 @@ int kobject_rename(struct kobject *kobj,
 			       "to '%s' as '%s' is already in existence.\n",
 			       kobject_name(kobj), new_name, new_name);
 			kobject_put(temp_kobj);
+			kobject_put(kobj);
 			return -EINVAL;
 		}
 	}

Thanks, but this is already fixed up with a patch from Eric in my tree in a different way.

greg k-h

#2 lore raw
Quoted 37 lines · Greg KH
Quoted 25 lines · Kenji Kaneshige

Hi,

I found a possible kobject reference counter leak problem in kobject_rename(). The following patch will fix it.

Thanks,
Kenji Kaneshige

Fix possible kobject reference counter leak in kobject_rename().

If kobject_rename() failed because of name collision, we must call kobject_put() for specified kobject before return.

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

Index: linux-2.6.27-rc4/lib/kobject.c
===================================================================

lib/kobject.c int kobject_rename(struct kobject *kobj, · line 417

Quoted 7 lines
lib/kobject.c +1 -0
@@ -411,6 +411,7 @@ int kobject_rename(struct kobject *kobj,
 			       "to '%s' as '%s' is already in existence.\n",
 			       kobject_name(kobj), new_name, new_name);
 			kobject_put(temp_kobj);
+			kobject_put(kobj);
 			return -EINVAL;
 		}
 	}

Thanks, but this is already fixed up with a patch from Eric in my tree in a different way.

Quoted 3 lines

greg k-h

Ah, I see. I didn't notice that. Thank you for the information.

Thanks,
Kenji Kaneshige