Skip to content

Commit ae37cea

Browse files
authored
FreeBSD: Prevent a NULL reference in 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. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> Closes #11152
1 parent a4246bc commit ae37cea

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)