From 1bf3bf0e2986ac0b8be18b2e2952f39353cc5daa Mon Sep 17 00:00:00 2001 From: Gvozden Neskovic Date: Sat, 9 Jul 2016 18:37:11 +0200 Subject: [PATCH] Fix handling of errors nvlist in zfs_ioc_recv_new() zfs_ioc_recv_impl() is changed to always allocate the 'errors' nvlist, its callers are responsible for freeing it. Signed-off-by: Gvozden Neskovic Signed-off-by: Brian Behlendorf Closes #4829 --- module/zfs/zfs_ioctl.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index f607225d14..37104fb9fb 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -4054,8 +4054,8 @@ static boolean_t zfs_ioc_recv_inject_err; #endif /* - * On failure the 'errors' nvlist may be allocated and will contain a - * descriptions of the failures. It's the callers responsibilty to free. + * nvlist 'errors' is always allocated. It will contain descriptions of + * encountered errors, if any. It's the callers responsibility to free. */ static int zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, @@ -4072,7 +4072,10 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, boolean_t first_recvd_props = B_FALSE; file_t *input_fp; - *errors = NULL; + *read_bytes = 0; + *errflags = 0; + *errors = fnvlist_alloc(); + input_fp = getf(input_fd); if (input_fp == NULL) return (SET_ERROR(EBADF)); @@ -4082,10 +4085,6 @@ zfs_ioc_recv_impl(char *tofs, char *tosnap, char *origin, if (error != 0) goto out; - *read_bytes = 0; - *errflags = 0; - *errors = fnvlist_alloc(); - /* * Set properties before we receive the stream so that they are applied * to the new data. Note that we must call dmu_recv_stream() if