block: blkdev_get() should access ->bd_disk only after success
authorTejun Heo <tj@kernel.org>
Wed, 1 Jun 2011 06:27:41 +0000 (08:27 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Wed, 1 Jun 2011 06:28:47 +0000 (08:28 +0200)
commit4c49ff3fe128ca68dabd07537415c419ad7f82f9
tree58898648d2b9d896804fa98fce9eecb2724e2a75
parent4495a7d41dbda03841c2a1c2a5ce7135a45131ba
block: blkdev_get() should access ->bd_disk only after success

d4dc210f69 (block: don't block events on excl write for non-optical
devices) added dereferencing of bdev->bd_disk to test
GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; however, bdev->bd_disk can be
%NULL if open failed which can lead to an oops.

Test the flag after testing open was successful, not before.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: David Miller <davem@davemloft.net>
Tested-by: David Miller <davem@davemloft.net>
Cc: stable@kernel.org
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
fs/block_dev.c