aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2012-02-08 14:03:38 -0500
committerJens Axboe <axboe@kernel.dk>2012-02-08 14:03:38 -0500
commit3f9a5aabd0a9fe0e0cd308506f48963d79169aa7 (patch)
tree89dd32775e498dcb50da8cfc5388400c637725c5 /drivers/block
parentcdccaa9467b982d57b139818d15e1e994feca372 (diff)
floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
add_disk() takes gendisk reference on request queue. If driver failed during initialization and never called add_disk() then that extra reference is not taken. That reference is put in put_disk(). floppy driver allocates the disk, allocates queue, sets disk->queue and then relizes that floppy controller is not present. It tries to tear down everything and tries to put a reference down in put_disk() which was never taken. In such error cases cleanup disk->queue before calling put_disk() so that we never try to put down a reference which was never taken in first place. Reported-and-tested-by: Suresh Jayaraman <sjayaraman@suse.com> Tested-by: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de> Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/floppy.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 510fb10ec45a..401ba7833212 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4368,8 +4368,14 @@ out_unreg_blkdev:
4368out_put_disk: 4368out_put_disk:
4369 while (dr--) { 4369 while (dr--) {
4370 del_timer_sync(&motor_off_timer[dr]); 4370 del_timer_sync(&motor_off_timer[dr]);
4371 if (disks[dr]->queue) 4371 if (disks[dr]->queue) {
4372 blk_cleanup_queue(disks[dr]->queue); 4372 blk_cleanup_queue(disks[dr]->queue);
4373 /*
4374 * put_disk() is not paired with add_disk() and
4375 * will put queue reference one extra time. fix it.
4376 */
4377 disks[dr]->queue = NULL;
4378 }
4373 put_disk(disks[dr]); 4379 put_disk(disks[dr]);
4374 } 4380 }
4375 return err; 4381 return err;