diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index b17b105ca3..b46a4f122c 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -2640,6 +2640,7 @@ recv_read_nvlist(libzfs_handle_t *hdl, int fd, int len, nvlist_t **nvp, if (len > hdl->libzfs_max_nvlist) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "nvlist too large")); + free(buf); return (ENOMEM); } diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 301c8ddbab..651bca2978 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -1060,6 +1060,9 @@ libzfs_init(void) if ((error = zfs_nicestrtonum(hdl, env, &hdl->libzfs_max_nvlist))) { errno = error; + (void) close(hdl->libzfs_fd); + (void) fclose(hdl->libzfs_mnttab); + free(hdl); return (NULL); } } else {