mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
rbd: drop dev reference on error in rbd_open()
If a read-only rbd device is opened for writing in rbd_open(), it
returns without dropping the just-acquired device reference.
Fix this by moving the read-only check before getting the reference.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit 340c7a2b2c
)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2c130889f5
commit
a871375b55
1 changed files with 3 additions and 4 deletions
|
@ -250,13 +250,12 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
|
|||
{
|
||||
struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
|
||||
|
||||
rbd_get_dev(rbd_dev);
|
||||
|
||||
set_device_ro(bdev, rbd_dev->read_only);
|
||||
|
||||
if ((mode & FMODE_WRITE) && rbd_dev->read_only)
|
||||
return -EROFS;
|
||||
|
||||
rbd_get_dev(rbd_dev);
|
||||
set_device_ro(bdev, rbd_dev->read_only);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue