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 <neskovic@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #4829
This commit is contained in:
Gvozden Neskovic 2016-07-09 18:37:11 +02:00 committed by Brian Behlendorf
parent 81edd3e834
commit 1bf3bf0e29

View File

@ -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