mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
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>
This commit is contained in:
parent
4495a7d41d
commit
4c49ff3fe1
@ -1272,8 +1272,8 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
|
||||
* individual writeable reference is too fragile given the
|
||||
* way @mode is used in blkdev_get/put().
|
||||
*/
|
||||
if ((disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE) &&
|
||||
!res && (mode & FMODE_WRITE) && !bdev->bd_write_holder) {
|
||||
if (!res && (mode & FMODE_WRITE) && !bdev->bd_write_holder &&
|
||||
(disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE)) {
|
||||
bdev->bd_write_holder = true;
|
||||
disk_block_events(disk);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user