]> git.karo-electronics.de Git - karo-tx-linux.git/commit
floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
authorVivek Goyal <vgoyal@redhat.com>
Wed, 8 Feb 2012 19:03:38 +0000 (20:03 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 9 Aug 2012 23:24:33 +0000 (00:24 +0100)
commite5dd68ebb5ee6c2defe90afd9ef98dca7e5a70b7
treeb63934360db4c3b9b246297962607d912223ff07
parentb75bfc42974aaf089ae7eae5d3c6bf362f57ee93
floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called

commit 3f9a5aabd0a9fe0e0cd308506f48963d79169aa7 upstream.

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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/block/floppy.c