From 24f1aa023ad3cb2f328883e78f517de6dc40091d Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Thu, 5 Aug 2021 15:32:57 +0000 Subject: libzfs_sendrecv: Initialize in case of failure In zfs_send_progress, initialize \*bytes_written and \*blocks_visited in case we have to return early due to ioctl failure. Reviewed-by: Brian Behlendorf Signed-off-by: Ryan Moeller Closes #12967 --- lib/libzfs/libzfs_sendrecv.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/libzfs') diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index fea49e3ab..d1538d146 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -883,6 +883,10 @@ zfs_send_progress(zfs_handle_t *zhp, int fd, uint64_t *bytes_written, { zfs_cmd_t zc = {"\0"}; + if (bytes_written != NULL) + *bytes_written = 0; + if (blocks_visited != NULL) + *blocks_visited = 0; (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); zc.zc_cookie = fd; if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_SEND_PROGRESS, &zc) != 0) -- cgit v1.2.3