[PATCH] tools: power: cpupower: bench: parse.c: Cleaning up use of a non-allocated file resource
From: Rickard Strandqvist
Date: Fri May 30 2014 - 20:25:08 EST
Removing the risk of using a non-allocated file resource
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@xxxxxxxxxxxxxxxxxx>
---
tools/power/cpupower/bench/parse.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
index 543bba1..abc026a 100644
--- a/tools/power/cpupower/bench/parse.c
+++ b/tools/power/cpupower/bench/parse.c
@@ -103,13 +103,16 @@ FILE *prepare_output(const char *dirname)
output = fopen(filename, "w+");
if (output == NULL) {
perror("fopen");
- fprintf(stderr, "error: unable to open logfile\n");
+ fprintf(stderr, "error: unable to open logfile: %s\n",
+ filename);
+ goto out;
}
fprintf(stdout, "Logfile: %s\n", filename);
- free(filename);
fprintf(output, "#round load sleep performance powersave percentage\n");
+out:
+ free(filename);
return output;
}
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/