Oops w/sysfs when closing a disconnected usb serial device

From: Mike Gorse
Date: Sun Nov 30 2003 - 19:21:17 EST


With 2.6.0-test11, I get a panic if I disconnect a USB serial device with
a fd open on it and then close the fd. When the device is disconnected,
usb_disconnect calls usb_disable_device, which calls device_del, which
calls kobject_del, which removes the device's sysfs directory. If a user
space program has the tts device open, then kobject_cleanup and
destroy_serial do not get called until the device is closed, but by then
the kobject_del call to the interface has caused the tty device's sysfs
directory to be nuked from under it. Eventually sysfs_remove_dir is
called and eventually calls simple_rmdir with a dentry with a NULL
d_inode, causing an oops. I can make the Oops go away with the following
patch:

--- fs/sysfs/dir.c.orig 2003-11-30 18:59:34.395284712 -0500
+++ fs/sysfs/dir.c 2003-11-30 18:59:50.944768808 -0500
@@ -83,7 +83,7 @@
struct dentry * parent = dget(d->d_parent);
down(&parent->d_inode->i_sem);
d_delete(d);
- simple_rmdir(parent->d_inode,d);
+ if (d->d_inode) simple_rmdir(parent->d_inode,d);

pr_debug(" o %s removing done (%d)\n",d->d_name.name,
atomic_read(&d->d_count));

-- Michael Gorse / AIM:linvortex / http://mgorse.home.dhs.org --
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/