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 <behlendorf1@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Ka Ho Ng <khng@freebsdfoundation.org>
Closes #11149
This commit is contained in:
khng300 2020-11-05 08:50:08 +08:00 committed by GitHub
parent 71ae6a9d23
commit a4246bce50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -158,6 +158,7 @@ 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); rc = fo_read(fp, &auio, td->td_ucred, FOF_OFFSET, td);
if (rc) if (rc)
return (SET_ERROR(rc)); return (SET_ERROR(rc));
if (resid)
*resid = auio.uio_resid; *resid = auio.uio_resid;
*offp += count - auio.uio_resid; *offp += count - auio.uio_resid;
return (SET_ERROR(0)); return (SET_ERROR(0));