From a4246bce5024df202e7c41a682c3f74555777197 Mon Sep 17 00:00:00 2001 From: khng300 Date: Thu, 5 Nov 2020 08:50:08 +0800 Subject: [PATCH] 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 Reviewed-by: Allan Jude Signed-off-by: Ka Ho Ng Closes #11149 --- module/os/freebsd/zfs/zfs_file_os.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/os/freebsd/zfs/zfs_file_os.c b/module/os/freebsd/zfs/zfs_file_os.c index d86eeceab..8fb259f4b 100644 --- a/module/os/freebsd/zfs/zfs_file_os.c +++ b/module/os/freebsd/zfs/zfs_file_os.c @@ -158,7 +158,8 @@ zfs_file_read_impl(zfs_file_t *fp, void *buf, size_t count, loff_t *offp, rc = fo_read(fp, &auio, td->td_ucred, FOF_OFFSET, td); if (rc) return (SET_ERROR(rc)); - *resid = auio.uio_resid; + if (resid) + *resid = auio.uio_resid; *offp += count - auio.uio_resid; return (SET_ERROR(0)); }