From 1ad31aec3288cc0a848d67afa59e753a6e0294cb Mon Sep 17 00:00:00 2001 From: David Goulet Date: Mon, 22 Sep 2014 10:55:52 -0400 Subject: [PATCH] Fix: possible file descriptor leak in error path Fixes Coverity issue 1225086. Signed-off-by: David Goulet --- src/bin/lttng/commands/list.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 96ccdb039..318896559 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -110,7 +110,7 @@ static void usage(FILE *ofp) static char *get_cmdline_by_pid(pid_t pid) { int ret; - FILE *fp; + FILE *fp = NULL; char *cmdline = NULL; char path[20]; /* Can't go bigger than /proc/65535/cmdline */ @@ -130,9 +130,11 @@ static char *get_cmdline_by_pid(pid_t pid) if (ret < 0) { perror("fread proc list"); } - fclose(fp); end: + if (fp) { + fclose(fp); + } return cmdline; } -- 2.34.1