Messages in this thread Patch in this message |  | | Date | Tue, 27 May 2003 11:29:53 -0400 (EDT) | From | Pavel Roskin <> | Subject | [PATCH] Graceful failure in devfs_remove() in 2.5.x |
| |
Hello!
It's already the second time that I encounter a kernel panic in the same place. When devfs_remove() is called on a non-existent file entry, the kernel panics and I have to reboot the system.
First time it was unregistering of pseudoterminals. This time it's ide-floppy module that doesn't register devfs entries if the media is absent but still tries to unregister them. The bug in ide-floppy will be reported separately.
The point of this message is that the failure in devfs_remove() is possible, especially with rarely used drivers. Secondly, is not fatal enough to justify an immediate panic and reboot. Thirdly, devfs misses a chance to tell the user what's going wrong.
This patch makes devfs_remove() print an error to the kernel log and continue. PRINTK is defined in fs/devfs/base.c to report errors in the cases like this one:
#define PRINTK(format, args...) \ {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
The patch:
============================================== --- linux.orig/fs/devfs/base.c +++ linux/fs/devfs/base.c @@ -1710,6 +1710,11 @@ void devfs_remove(const char *fmt, ...) if (n < 64 && buf[0]) { devfs_handle_t de = _devfs_find_entry(NULL, buf, 0);
+ if (!de) { + PRINTK ("(%s): not found, cannot remove\n", buf); + return; + } + write_lock(&de->parent->u.dir.lock); _devfs_unregister(de->parent, de); devfs_put(de); ============================================== The patch is against Linux 2.5.70.
Linux 2.4.21-rc4 already has protection against panic although it doesn't print the error message - see devfs_unlink() in fs/devfs/base.c
-- Regards, Pavel Roskin - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |