[lkml]   [2003]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] Graceful failure in devfs_remove() in 2.5.x

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;
+ }
_devfs_unregister(de->parent, 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

Pavel Roskin
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:35    [W:0.044 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site