Re: [PATCH] Mark kobjects as unitialized

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Saturday, March 8, 2008 - 10:06 pm

On Sun, Mar 09, 2008 at 03:37:16AM +0530, Balaji Rao wrote:

Ugh, that's horrible.  And people wonder why I hate the sysdev code :)

Does it also mean that when we do cleanup sysdev devices, we are freeing
a name that might not have been dynamically allocated?  If so, we need
to fix that as well.

A simple 'strdup' of the class name in sysdev_class_register() should
fix all of this, right?


Yes, that would be great to fix up, but probably unlikly so late in the
release cycle.

How about the patch below, does it work for you? (build tested only)

thanks,

greg k-h


---
 drivers/base/sys.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -130,13 +130,16 @@ static struct kset *system_kset;
 
 int sysdev_class_register(struct sysdev_class * cls)
 {
+	char *name;
+
 	pr_debug("Registering sysdev class '%s'\n",
 		 kobject_name(&cls->kset.kobj));
 	INIT_LIST_HEAD(&cls->drivers);
 	cls->kset.kobj.parent = &system_kset->kobj;
 	cls->kset.kobj.ktype = &ktype_sysdev_class;
 	cls->kset.kobj.kset = system_kset;
-	kobject_set_name(&cls->kset.kobj, cls->name);
+	name = kstrdup(cls->name, GFP_KERNEL);
+	kobject_set_name(&cls->kset.kobj, name);
 	return kset_register(&cls->kset);
 }
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Mark kobjects as unitialized, Balaji Rao, (Thu Mar 6, 9:53 am)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Thu Mar 6, 10:05 am)
Re: [PATCH] Mark kobjects as unitialized, Balaji Rao, (Thu Mar 6, 10:50 am)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Thu Mar 6, 11:05 am)
Re: [PATCH] Mark kobjects as unitialized, Balaji Rao, (Sat Mar 8, 3:07 pm)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Sat Mar 8, 10:06 pm)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Sat Mar 8, 11:16 pm)
Re: [PATCH] Mark kobjects as unitialized, Balaji Rao, (Sat Mar 8, 11:17 pm)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Sat Mar 8, 11:33 pm)
Re: [PATCH] Mark kobjects as unitialized, Balaji Rao, (Sat Mar 8, 11:36 pm)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Sun Mar 9, 12:03 am)
Re: [PATCH] Mark kobjects as unitialized, Balaji Rao, (Sun Mar 9, 12:21 am)
Re: [PATCH] Mark kobjects as unitialized, Mikael Pettersson, (Sun Mar 9, 3:49 am)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Mon Mar 10, 8:52 am)
Re: [PATCH] Mark kobjects as unitialized, Balaji Rao, (Mon Mar 10, 9:05 am)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Mon Mar 10, 10:20 am)
Re: [PATCH] Mark kobjects as unitialized, Greg KH, (Mon Mar 10, 10:20 am)