diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 0fffbaaf7c70..57498ca3cff8 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -849,8 +849,10 @@ libzfs_read_stdout_from_fd(int fd, char **lines[]) char **tmp_lines = NULL, **tmp; fp = fdopen(fd, "r"); - if (fp == NULL) + if (fp == NULL) { + close(fd); return (0); + } while (getline(&line, &len, fp) != -1) { tmp = realloc(tmp_lines, sizeof (*tmp_lines) * (lines_cnt + 1)); if (tmp == NULL) {