Skip to contentSkip to conversation

Driver Core fixes for 2.6.10-rc2

PATCH New Greg KH 1 participant 3 messages Nov 19, 2004

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 Driver Core fixes for 2.6.10-rc2

Hi,

Here are two bugfixes for the driver core / sysfs against 2.6.10-rc2.

Please pull from:

	bk://kernel.bkbits.net/gregkh/linux/driver-2.6

thanks,

greg k-h

p.s. I'll send these as patches in response to this email to lkml for those who want to see them.

 fs/sysfs/dir.c |    3 ++-
 lib/kobject.c  |    6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

-----

Gerd Knorr:
o fix kobject varargs bug

Maneesh Soni:
o fix oops in sysfs_remove_dir()

author
#1 lore raw

PATCH 1/1 Driver Core fixes for 2.6.10-rc2

ChangeSet 1.2164, 2004/11/19 08:47:13-08:00, [email protected]

[PATCH] fix kobject varargs bug

From: Gerd Knorr <[email protected]>

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.

 lib/kobject.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
lib/kobject.c +4 -2
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -232,11 +232,12 @@
 	va_list args;
 	char * name;
 
-	va_start(args,fmt);
 	/* 
 	 * First, try the static array 
 	 */
+	va_start(args,fmt);
 	need = vsnprintf(kobj->name,limit,fmt,args);
+	va_end(args);
 	if (need < limit) 
 		name = kobj->name;
 	else {
@@ -249,7 +250,9 @@
 			error = -ENOMEM;
 			goto Done;
 		}
+		va_start(args,fmt);
 		need = vsnprintf(name,limit,fmt,args);
+		va_end(args);
 
 		/* Still? Give up. */
 		if (need >= limit) {
@@ -266,7 +269,6 @@
 	/* Now, set the new name */
 	kobj->k_name = name;
  Done:
-	va_end(args);
 	return error;
 }
 
author
#2 lore raw

ChangeSet 1.2165, 2004/11/19 08:47:38-08:00, [email protected]

[PATCH] fix oops in sysfs_remove_dir()

The following patch should avoid the sysfs_remove_dir() oops you are seeing while device removal. It anyway fixes the obvious error and is needed. But it will not make any change to the first error you are seeing while connecting the device.

o Following patch avoids the sysfs_remove_dir() oops when it is passed a kobject with NULL dentry.

 fs/sysfs/dir.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
fs/sysfs/dir.c +2 -1
diff -Nru a/fs/sysfs/dir.c b/fs/sysfs/dir.c
@@ -268,7 +268,7 @@
 void sysfs_remove_dir(struct kobject * kobj)
 {
 	struct dentry * dentry = dget(kobj->dentry);
-	struct sysfs_dirent * parent_sd = dentry->d_fsdata;
+	struct sysfs_dirent * parent_sd;
 	struct sysfs_dirent * sd, * tmp;
 
 	if (!dentry)
@@ -276,6 +276,7 @@
 
 	pr_debug("sysfs %s: removing dir\n",dentry->d_name.name);
 	down(&dentry->d_inode->i_sem);
+	parent_sd = dentry->d_fsdata;
 	list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) {
 		if (!sd->s_element || !(sd->s_type & SYSFS_NOT_PINNED))
 			continue;