public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -mm] kobject_add error handling when set name failed
@ 2007-12-14  9:24 Dave Young
  2007-12-14 22:23 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Young @ 2007-12-14  9:24 UTC (permalink / raw)
  To: gregkh; +Cc: akpm, linux-kernel

In kobject_add, when kobject_set_name failed we should put the kobj and return.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
lib/kobject.c |   11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff -upr linux/lib/kobject.c linux.new/lib/kobject.c
--- linux/lib/kobject.c	2007-12-14 17:14:03.000000000 +0800
+++ linux.new/lib/kobject.c	2007-12-14 17:17:48.000000000 +0800
@@ -228,8 +228,13 @@ int kobject_add(struct kobject * kobj)
 
 	if (!(kobj = kobject_get(kobj)))
 		return -ENOENT;
-	if (!kobj->k_name)
-		kobject_set_name(kobj, "NO_NAME");
+	if (!kobj->k_name) {
+		error = kobject_set_name(kobj, "NO_NAME"));
+		if (error) {
+			kobject_put(kobj);
+			return error;
+		}
+	}
 	if (!*kobj->k_name) {
 		pr_debug("kobject (%p) attempted to be registered with no "
 			 "name!\n", kobj);
@@ -371,7 +376,7 @@ void kobject_init_ng(struct kobject *kob
 		goto error;
 	}
 	if (!ktype) {
-		err_str = "must have a ktype to be initialized properly!\n";
+		err_str = "must have a ktype to be initialized properly!";
 		goto error;
 	}
 	if (atomic_read(&kobj->kref.refcount)) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH -mm] kobject_add error handling when set name failed
  2007-12-14  9:24 [PATCH -mm] kobject_add error handling when set name failed Dave Young
@ 2007-12-14 22:23 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2007-12-14 22:23 UTC (permalink / raw)
  To: Dave Young; +Cc: akpm, linux-kernel

On Fri, Dec 14, 2007 at 05:24:05PM +0800, Dave Young wrote:
> In kobject_add, when kobject_set_name failed we should put the kobj and return.
> 
> Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 
> 
> ---
> lib/kobject.c |   11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff -upr linux/lib/kobject.c linux.new/lib/kobject.c
> --- linux/lib/kobject.c	2007-12-14 17:14:03.000000000 +0800
> +++ linux.new/lib/kobject.c	2007-12-14 17:17:48.000000000 +0800
> @@ -228,8 +228,13 @@ int kobject_add(struct kobject * kobj)
>  
>  	if (!(kobj = kobject_get(kobj)))
>  		return -ENOENT;
> -	if (!kobj->k_name)
> -		kobject_set_name(kobj, "NO_NAME");
> +	if (!kobj->k_name) {
> +		error = kobject_set_name(kobj, "NO_NAME"));
> +		if (error) {
> +			kobject_put(kobj);
> +			return error;
> +		}
> +	}

Thanks, but I have a pending patch from Kay in my inbox that messes up
this patch, as it drops most of this nonsense :)

>  	if (!*kobj->k_name) {
>  		pr_debug("kobject (%p) attempted to be registered with no "
>  			 "name!\n", kobj);
> @@ -371,7 +376,7 @@ void kobject_init_ng(struct kobject *kob
>  		goto error;
>  	}
>  	if (!ktype) {
> -		err_str = "must have a ktype to be initialized properly!\n";
> +		err_str = "must have a ktype to be initialized properly!";
>  		goto error;

Oops, good catch, I'll just go add this change to my tree.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-14 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-14  9:24 [PATCH -mm] kobject_add error handling when set name failed Dave Young
2007-12-14 22:23 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox