* [PATCH] Graceful failure in devfs_remove() in 2.5.x
@ 2003-05-27 15:29 Pavel Roskin
2003-05-28 9:46 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Roskin @ 2003-05-27 15:29 UTC (permalink / raw)
To: devfs; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Graceful failure in devfs_remove() in 2.5.x
2003-05-27 15:29 [PATCH] Graceful failure in devfs_remove() in 2.5.x Pavel Roskin
@ 2003-05-28 9:46 ` Christoph Hellwig
2003-05-28 16:00 ` Pavel Roskin
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2003-05-28 9:46 UTC (permalink / raw)
To: Pavel Roskin; +Cc: devfs, linux-kernel
On Tue, May 27, 2003 at 11:29:53AM -0400, Pavel Roskin wrote:
> 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:
Patch looks okay _except_ for use of this gross macro. Just
ise plain printk instead.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Graceful failure in devfs_remove() in 2.5.x
2003-05-28 9:46 ` Christoph Hellwig
@ 2003-05-28 16:00 ` Pavel Roskin
0 siblings, 0 replies; 3+ messages in thread
From: Pavel Roskin @ 2003-05-28 16:00 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: devfs, linux-kernel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 532 bytes --]
On Wed, 28 May 2003, Christoph Hellwig wrote:
> On Tue, May 27, 2003 at 11:29:53AM -0400, Pavel Roskin wrote:
> > 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:
>
> Patch looks okay _except_ for use of this gross macro. Just
> ise plain printk instead.
I always try to follow the existing code style, but if you want me to make
an exception, here it is. Fixed patch is attached.
--
Regards,
Pavel Roskin
[-- Attachment #2: Type: TEXT/PLAIN, Size: 436 bytes --]
--- linux.orig/fs/devfs/base.c
+++ linux/fs/devfs/base.c
@@ -1710,6 +1710,12 @@ void devfs_remove(const char *fmt, ...)
if (n < 64 && 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);
+ return;
+ }
+
write_lock(&de->parent->u.dir.lock);
_devfs_unregister(de->parent, de);
devfs_put(de);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-28 15:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-27 15:29 [PATCH] Graceful failure in devfs_remove() in 2.5.x Pavel Roskin
2003-05-28 9:46 ` Christoph Hellwig
2003-05-28 16:00 ` Pavel Roskin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®