Commit 9d1f9419 authored by Mikael Pettersson's avatar Mikael Pettersson Committed by Jens Axboe

[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.
parent ed245b59
...@@ -4219,8 +4219,6 @@ int __init floppy_init(void) ...@@ -4219,8 +4219,6 @@ int __init floppy_init(void)
{ {
int i,unit,drive; int i,unit,drive;
register_sys_device(&device_floppy);
raw_cmd = NULL; raw_cmd = NULL;
devfs_handle = devfs_mk_dir (NULL, "floppy", NULL); devfs_handle = devfs_mk_dir (NULL, "floppy", NULL);
...@@ -4347,6 +4345,9 @@ int __init floppy_init(void) ...@@ -4347,6 +4345,9 @@ int __init floppy_init(void)
register_disk(NULL, mk_kdev(MAJOR_NR,TOMINOR(drive)+i*4), register_disk(NULL, mk_kdev(MAJOR_NR,TOMINOR(drive)+i*4),
1, &floppy_fops, 0); 1, &floppy_fops, 0);
} }
register_sys_device(&device_floppy);
return have_no_fdc; return have_no_fdc;
} }
...@@ -4529,6 +4530,7 @@ void cleanup_module(void) ...@@ -4529,6 +4530,7 @@ void cleanup_module(void)
{ {
int dummy; int dummy;
unregister_sys_device(&device_floppy);
devfs_unregister (devfs_handle); devfs_unregister (devfs_handle);
unregister_blkdev(MAJOR_NR, "fd"); unregister_blkdev(MAJOR_NR, "fd");
......
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