Skip to content

Commit 4f6a35e

Browse files
khng300jsai20
authored andcommitted
FreeBSD: Prevent NULL pointer dereference of resid
spa_config_load() passes NULL into resid when doing zfs_file_read(). This would trip over when vfs.zfs.autoimport_disable=0. Sponsored by: The FreeBSD Foundation Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Allan Jude <[email protected]> Signed-off-by: Ka Ho Ng <[email protected]> Closes openzfs#11149
1 parent 2d62212 commit 4f6a35e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

module/os/freebsd/zfs/zfs_file_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ zfs_file_read_impl(zfs_file_t *fp, void *buf, size_t count, loff_t *offp,
158158
rc = fo_read(fp, &auio, td->td_ucred, FOF_OFFSET, td);
159159
if (rc)
160160
return (SET_ERROR(rc));
161-
*resid = auio.uio_resid;
161+
if (resid)
162+
*resid = auio.uio_resid;
162163
*offp += count - auio.uio_resid;
163164
return (SET_ERROR(0));
164165
}

0 commit comments

Comments
 (0)