aboutsummaryrefslogtreecommitdiffstats
path: root/block/bdev.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/bdev.c')
-rw-r--r--block/bdev.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/block/bdev.c b/block/bdev.c
index fc8d28d77495f..de76320ef9dfe 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -828,8 +828,10 @@ struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
goto free_handle;
/* Blocking writes requires exclusive opener */
- if (mode & BLK_OPEN_RESTRICT_WRITES && !holder)
- return ERR_PTR(-EINVAL);
+ if (mode & BLK_OPEN_RESTRICT_WRITES && !holder) {
+ ret = -EINVAL;
+ goto free_handle;
+ }
bdev = blkdev_get_no_open(dev);
if (!bdev) {