aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-08-10 16:12:07 -0400
committerSage Weil <sage@inktank.com>2012-09-21 23:48:54 -0400
commit340c7a2b2c9a2da640af28a8c196356484ac8b50 (patch)
tree4bd52ff7fc913c1b9bcb35e13c4df3edbb8067df /drivers/block
parent5698bd757d55b1bb87edd1a9744ab09c142abfc2 (diff)
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>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9917943a3572..54a55f03115d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -246,13 +246,12 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
246{ 246{
247 struct rbd_device *rbd_dev = bdev->bd_disk->private_data; 247 struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
248 248
249 rbd_get_dev(rbd_dev);
250
251 set_device_ro(bdev, rbd_dev->read_only);
252
253 if ((mode & FMODE_WRITE) && rbd_dev->read_only) 249 if ((mode & FMODE_WRITE) && rbd_dev->read_only)
254 return -EROFS; 250 return -EROFS;
255 251
252 rbd_get_dev(rbd_dev);
253 set_device_ro(bdev, rbd_dev->read_only);
254
256 return 0; 255 return 0;
257} 256}
258 257