aboutsummaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2013-03-08 10:48:18 -0800
committerBrian Behlendorf <[email protected]>2015-01-30 14:44:14 -0800
commit0365064a9726f6bb6e148611a6e42fa80302d083 (patch)
tree528aa5f09032350ba036ffc1d670c82ab7aa1591 /module
parenta127e841dee20340b300e98b6d4b62f9ad41a47b (diff)
Handle closing an unopened ZVOL
Thank to commit a4430fce691d492aec382de0dfa937c05ee16500 we're now correctly returning EROFS when opening a zvol on a read-only pool. Unfortunately, it looks like this causes us to trigger some unexpected behavior by __blkdev_get(). In the failure case it's possible __blkdev_get() will call __blkdev_put() for a bdev which was never successfully opened. This results in us trying to close the device again and hitting the NULL dereference. Signed-off-by: Brian Behlendorf <[email protected]> Closes #1343
Diffstat (limited to 'module')
-rw-r--r--module/zfs/zvol.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index 8c43e198a..4febbb6bf 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -1055,11 +1055,11 @@ zvol_release(struct gendisk *disk, fmode_t mode)
drop_mutex = 1;
}
- ASSERT3P(zv, !=, NULL);
- ASSERT3U(zv->zv_open_count, >, 0);
- zv->zv_open_count--;
- if (zv->zv_open_count == 0)
- zvol_last_close(zv);
+ if (zv->zv_open_count > 0) {
+ zv->zv_open_count--;
+ if (zv->zv_open_count == 0)
+ zvol_last_close(zv);
+ }
if (drop_mutex)
mutex_exit(&zvol_state_lock);