Skip to content

Commit

Permalink
floppy: Fix a crash during rmmod
Browse files Browse the repository at this point in the history
floppy driver does not call add_disk() on all the drives hence we don't take
gendisk reference on request queue for these drives. Don't call put_disk()
with disk->queue set, otherwise we try to put the reference we never took.

Reported-and-tested-by: Dirk Gouders <[email protected]>
Signed-off-by: Vivek Goyal<[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
rhvgoyal authored and axboe committed Feb 8, 2012
1 parent 3f9a5aa commit 4609dff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -4585,6 +4585,15 @@ static void __exit floppy_module_exit(void)
platform_device_unregister(&floppy_device[drive]);
}
blk_cleanup_queue(disks[drive]->queue);

/*
* These disks have not called add_disk(). Don't put down
* queue reference in put_disk().
*/
if (!(allowed_drive_mask & (1 << drive)) ||
fdc_state[FDC(drive)].version == FDC_NONE)
disks[drive]->queue = NULL;

put_disk(disks[drive]);
}

Expand Down

0 comments on commit 4609dff

Please sign in to comment.