lkml.org 
[lkml]   [2002]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH] 2.5.34 floppy driver init/exit fixes
The 2.5 floppy driver has for a long time has two init/exit bugs:
1. It calls register_sys_device() on init, but fails to call
unregister_sys_device() in exit. This leads to data structure
corruption if floppy is a module and it gets unloaded.
2. If calls register_sys_device() early on init, but fails to call
unregister_sys_device() if init fails. Again, this leads to
data structure corruption.

The patch below fixes both these problems. I've used it since 2.5.13
or so. Please apply.

/Mikael

diff -ruN linux-2.5.34/drivers/block/floppy.c linux-2.5.34.floppy/drivers/block/floppy.c
--- linux-2.5.34/drivers/block/floppy.c Mon Sep 9 21:15:28 2002
+++ linux-2.5.34.floppy/drivers/block/floppy.c Mon Sep 9 21:20:51 2002
@@ -4219,8 +4219,6 @@
{
int i,unit,drive;

- register_sys_device(&device_floppy);
-
raw_cmd = NULL;

devfs_handle = devfs_mk_dir (NULL, "floppy", NULL);
@@ -4347,6 +4345,9 @@
register_disk(NULL, mk_kdev(MAJOR_NR,TOMINOR(drive)+i*4),
1, &floppy_fops, 0);
}
+
+ register_sys_device(&device_floppy);
+
return have_no_fdc;
}

@@ -4529,6 +4530,7 @@
{
int dummy;

+ unregister_sys_device(&device_floppy);
devfs_unregister (devfs_handle);
unregister_blkdev(MAJOR_NR, "fd");

-
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/
\
 
 \ /
  Last update: 2005-03-22 13:28    [W:0.035 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site