diff options
author | Colin Ian King <colin.king@canonical.com> | 2014-06-19 19:54:04 +0100 |
---|---|---|
committer | Amit Kucheria <amit.kucheria@linaro.org> | 2014-06-20 15:52:35 +0530 |
commit | 6d6182f8229d08f53db166ec6f58e6520258ff4f (patch) | |
tree | 9deab23d02ddfce7e79b20aa52afb019b3a1bea7 | |
parent | 03ba1e995f86a28ecb582b12dae6dd70f40c13eb (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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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++) |