libzfs: Don't leak buf if nvlist is too large
Resolves FreeBSD Coverity defect: CID 1432398: Resource leaks (RESOURCE_LEAK) libzfs: don't leak hdl if there is an error reading env var Resolves FreeBSD Coverity defect: CID 1432395: Resource leaks (RESOURCE_LEAK) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Allan Jude <allanjude@freebsd.org> Closes #10882
This commit is contained in:
parent
dacb4f6a61
commit
56e69c1e9c
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue