Skip to content

Commit 6c4867f

Browse files
Carsten Emdeaxboe
authored andcommitted
floppy: use del_timer_sync() in init cleanup
When no floppy is found the module code can be released while a timer function is pending or about to be executed. CPU0 CPU1 floppy_init() timer_softirq() spin_lock_irq(&base->lock); detach_timer(); spin_unlock_irq(&base->lock); -> Interrupt del_timer(); return -ENODEV; module_cleanup(); <- EOI call_timer_fn(); OOPS Use del_timer_sync() to prevent this. Signed-off-by: Carsten Emde <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Jens Axboe <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d11bb44 commit 6c4867f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/block/floppy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,7 +4250,7 @@ static int __init floppy_init(void)
42504250
use_virtual_dma = can_use_virtual_dma & 1;
42514251
fdc_state[0].address = FDC1;
42524252
if (fdc_state[0].address == -1) {
4253-
del_timer(&fd_timeout);
4253+
del_timer_sync(&fd_timeout);
42544254
err = -ENODEV;
42554255
goto out_unreg_region;
42564256
}
@@ -4261,7 +4261,7 @@ static int __init floppy_init(void)
42614261
fdc = 0; /* reset fdc in case of unexpected interrupt */
42624262
err = floppy_grab_irq_and_dma();
42634263
if (err) {
4264-
del_timer(&fd_timeout);
4264+
del_timer_sync(&fd_timeout);
42654265
err = -EBUSY;
42664266
goto out_unreg_region;
42674267
}
@@ -4318,7 +4318,7 @@ static int __init floppy_init(void)
43184318
user_reset_fdc(-1, FD_RESET_ALWAYS, false);
43194319
}
43204320
fdc = 0;
4321-
del_timer(&fd_timeout);
4321+
del_timer_sync(&fd_timeout);
43224322
current_drive = 0;
43234323
initialized = true;
43244324
if (have_no_fdc) {
@@ -4368,7 +4368,7 @@ static int __init floppy_init(void)
43684368
unregister_blkdev(FLOPPY_MAJOR, "fd");
43694369
out_put_disk:
43704370
while (dr--) {
4371-
del_timer(&motor_off_timer[dr]);
4371+
del_timer_sync(&motor_off_timer[dr]);
43724372
if (disks[dr]->queue)
43734373
blk_cleanup_queue(disks[dr]->queue);
43744374
put_disk(disks[dr]);

0 commit comments

Comments
 (0)