Skip to content

Commit 160a45d

Browse files
committed
Prevent a NULL reference in the zvol_cdev_open.
Check if the ZVOL has been written before calling zil_async_to_sync. The ZIL will be opened on the first write, not earlier. Signed-off-by: Mariusz Zaborski <[email protected]>
1 parent a4246bc commit 160a45d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

module/os/freebsd/zfs/zvol_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
891891
if (flags & (FSYNC | FDSYNC)) {
892892
zsd = &zv->zv_zso->zso_dev;
893893
zsd->zsd_sync_cnt++;
894-
if (zsd->zsd_sync_cnt == 1)
894+
if (zsd->zsd_sync_cnt == 1 &&
895+
(zv->zv_flags & ZVOL_WRITTEN_TO) != 0)
895896
zil_async_to_sync(zv->zv_zilog, ZVOL_OBJ);
896897
}
897898

0 commit comments

Comments
 (0)