Commit 2632cc57 authored by Andrew Morton's avatar Andrew Morton Committed by David Mosberger

[PATCH] Graceful failure in devfs_remove()

From: Pavel Roskin <proski@gnu.org>, via Christoph Hellwig <hch@infradead.org>

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.
parent ebd913f0
...@@ -1710,6 +1710,13 @@ void devfs_remove(const char *fmt, ...) ...@@ -1710,6 +1710,13 @@ void devfs_remove(const char *fmt, ...)
if (n < 64 && buf[0]) { if (n < 64 && buf[0]) {
devfs_handle_t de = _devfs_find_entry(NULL, buf, 0); devfs_handle_t de = _devfs_find_entry(NULL, buf, 0);
if (!de) {
printk(KERN_ERR "%s: %s not found, cannot remove\n",
__FUNCTION__, buf);
dump_stack();
return;
}
write_lock(&de->parent->u.dir.lock); write_lock(&de->parent->u.dir.lock);
_devfs_unregister(de->parent, de); _devfs_unregister(de->parent, de);
devfs_put(de); devfs_put(de);
......
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