aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2014-06-19 19:54:04 +0100
committerAmit Kucheria <amit.kucheria@linaro.org>2014-06-20 15:52:35 +0530
commit6d6182f8229d08f53db166ec6f58e6520258ff4f (patch)
tree9deab23d02ddfce7e79b20aa52afb019b3a1bea7
parent03ba1e995f86a28ecb582b12dae6dd70f40c13eb (diff)
Fix memory leak on error exit path
Free result if result->cstates cannot be allocated. Issue found by Coverity Scan. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
-rw-r--r--idlestat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/idlestat.c b/idlestat.c
index ec12d62..0b5349b 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -844,8 +844,10 @@ struct cpuidle_datas *cluster_data(struct cpuidle_datas *datas)
result->nrcpus = -1; /* the cluster */
result->cstates = calloc(sizeof(*result->cstates), 1);
- if (!result->cstates)
+ if (!result->cstates) {
+ free(result);
return NULL;
+ }
/* hack but negligeable overhead */
for (i = 0; i < datas->nrcpus; i++)