From 3e2ecae01c6de6f885eca2ea78f00db2d21065ef Mon Sep 17 00:00:00 2001 From: Giuseppe Di Natale Date: Tue, 9 May 2017 11:34:19 -0700 Subject: [PATCH] Fix coverity defects: CID 161638 CID 161638: Resource leak (RESOURCE_LEAK) Ensure the string array in print_zpool_script_help is freed in cases when there is an error. Reviewed-by: Brian Behlendorf Signed-off-by: Giuseppe Di Natale Closes #6111 --- cmd/zpool/zpool_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index edcfe2db7..6a54c92c3 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -4131,8 +4131,11 @@ print_zpool_script_help(char *name, char *path) rc = libzfs_run_process_get_stdout_nopath(path, argv, NULL, &lines, &lines_cnt); - if (rc != 0 || lines == NULL || lines_cnt <= 0) + if (rc != 0 || lines == NULL || lines_cnt <= 0) { + if (lines != NULL) + libzfs_free_str_array(lines, lines_cnt); return; + } for (int i = 0; i < lines_cnt; i++) if (!is_blank_str(lines[i]))