]> git.proxmox.com Git - mirror_zfs.git/commitdiff
libzfs_sendrecv: Fix leaked holds nvlist
authorRyan Moeller <freqlabs@FreeBSD.org>
Tue, 27 Jul 2021 13:48:42 +0000 (13:48 +0000)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 2 Feb 2022 01:02:05 +0000 (17:02 -0800)
There is no need to allocate a holds nvlist.  lzc_get_holds does that
for us.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #12967

lib/libzfs/libzfs_sendrecv.c

index 26990a876a814128a744f6b053ac345618d6d349..8cfb8185854a7f943c9094fb359e07d809673659 100644 (file)
@@ -349,12 +349,11 @@ send_iterate_snap(zfs_handle_t *zhp, void *arg)
        fnvlist_add_nvlist(sd->snapprops, snapname, nv);
        fnvlist_free(nv);
        if (sd->holds) {
-               nvlist_t *holds = fnvlist_alloc();
-               int err = lzc_get_holds(zhp->zfs_name, &holds);
-               if (err == 0) {
+               nvlist_t *holds;
+               if (lzc_get_holds(zhp->zfs_name, &holds) == 0) {
                        fnvlist_add_nvlist(sd->snapholds, snapname, holds);
+                       fnvlist_free(holds);
                }
-               fnvlist_free(holds);
        }
 
        zfs_close(zhp);