Skip to content

Commit

Permalink
floppy: fix use-after-free in module load failure path
Browse files Browse the repository at this point in the history
Commit 4882118 ("floppy: switch to one queue per drive instead of
sharing a queue") introduced a use-after-free.  We do "put_disk()" on
the disk device _before_ we then clean up the queue associated with that
disk.

Move the put_disk() down to avoid dereferencing a free'd data structure.

Cc: Jens Axboe <[email protected]>
Cc: Vivek Goyal <[email protected]>
Reported-and-tested-by: Randy Dunlap <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
torvalds committed Nov 6, 2010
1 parent 433039e commit c093ee4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -4363,9 +4363,9 @@ static int __init floppy_init(void)
out_put_disk:
while (dr--) {
del_timer(&motor_off_timer[dr]);
put_disk(disks[dr]);
if (disks[dr]->queue)
blk_cleanup_queue(disks[dr]->queue);
put_disk(disks[dr]);
}
return err;
}
Expand Down

0 comments on commit c093ee4

Please sign in to comment.