aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLisa Nguyen <lisa.nguyen@linaro.org>2016-11-07 18:22:55 -0800
committerLisa Nguyen <lisa.nguyen@linaro.org>2016-11-07 18:30:55 -0800
commit12e88e3d7950ec5832f78b1ba326afddec7af4c2 (patch)
treec3037bd88eb3841bbf1b7ee8eeea42c354abe9bb
parent45b478c763bfaefbda5518d4e6900193d1e65ad0 (diff)
downloadidlestat-12e88e3d7950ec5832f78b1ba326afddec7af4c2.tar.gz
Fix resource leak in energy_model.c
Coverity Scan detected a resource leak in energy_model.c. Refer to defect #84132. To fix the defect, change the way memory is allocated for the cluster_energy_table static variable. Signed-off-by: Lisa Nguyen <lisa.nguyen@linaro.org>
-rw-r--r--energy_model.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/energy_model.c b/energy_model.c
index 2ea6fdd..4940da1 100644
--- a/energy_model.c
+++ b/energy_model.c
@@ -171,8 +171,8 @@ int parse_energy_model(struct program_options *options)
return -1;
}
sscanf(buffer, "%*s %d", &clusters_in_energy_file);
- cluster_energy_table = calloc(sizeof(struct cluster_energy_info),
- clusters_in_energy_file);
+ cluster_energy_table = (struct cluster_energy_info *)realloc(cluster_energy_table,
+ clusters_in_energy_file * sizeof(struct cluster_energy_info));
continue;
}
if (strstr(buffer, "cluster") && !strstr(buffer, "cluster-")) {