Commit 0e8a2de6 authored by Andrew Morton's avatar Andrew Morton Committed by Greg Kroah-Hartman

[PATCH] fix kobject varargs bug

From: Gerd Knorr <kraxel@bytesex.org>

It uses the varargs list twice in a illegal way.  That doesn't harm on i386
by pure luck, but blows things up on amd64 machines.

Using var args list twice without calling va_start twice is illegal.
Signed-off-by: default avatarGerd Knorr <kraxel@bytesex.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 84ac4d4a
...@@ -232,11 +232,12 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...) ...@@ -232,11 +232,12 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
va_list args; va_list args;
char * name; char * name;
va_start(args,fmt);
/* /*
* First, try the static array * First, try the static array
*/ */
va_start(args,fmt);
need = vsnprintf(kobj->name,limit,fmt,args); need = vsnprintf(kobj->name,limit,fmt,args);
va_end(args);
if (need < limit) if (need < limit)
name = kobj->name; name = kobj->name;
else { else {
...@@ -249,7 +250,9 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...) ...@@ -249,7 +250,9 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
error = -ENOMEM; error = -ENOMEM;
goto Done; goto Done;
} }
va_start(args,fmt);
need = vsnprintf(name,limit,fmt,args); need = vsnprintf(name,limit,fmt,args);
va_end(args);
/* Still? Give up. */ /* Still? Give up. */
if (need >= limit) { if (need >= limit) {
...@@ -266,7 +269,6 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...) ...@@ -266,7 +269,6 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
/* Now, set the new name */ /* Now, set the new name */
kobj->k_name = name; kobj->k_name = name;
Done: Done:
va_end(args);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment