]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
block: use after free bug in __blkdev_get
authorNeil Brown <neilb@suse.de>
Mon, 26 Oct 2009 07:59:17 +0000 (08:59 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 26 Oct 2009 14:27:11 +0000 (15:27 +0100)
commit 0762b8bde9729f10f8e6249809660ff2ec3ad735
(from 14 months ago) introduced a use-after-free bug which has just
recently started manifesting in my md testing.
I tried git bisect to find out what caused the bug to start
manifesting, and it could have been the recent change to
blk_unregister_queue (48c0d4d4c04) but the results were inconclusive.

This patch certainly fixes my symptoms and looks correct as the two
calls are now in the same order as elsewhere in that function.

Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fs/block_dev.c

index 9cf4b926f8e47a509f0994ad0e696d79205335bb..8bed0557d88c17ac9600a179f8127d855e509bab 100644 (file)
@@ -1248,8 +1248,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
                        bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9);
                }
        } else {
-               put_disk(disk);
                module_put(disk->fops->owner);
+               put_disk(disk);
                disk = NULL;
                if (bdev->bd_contains == bdev) {
                        if (bdev->bd_disk->fops->open) {