aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2014-06-19 08:35:06 +0100
committerAmit Kucheria <amit.kucheria@linaro.org>2014-06-19 16:44:03 +0530
commitf5b9bdcb530a8871e6c65a617d41001b39bf4912 (patch)
tree953bd8668a716ba0f5fafd1a497dd67df55753b9
parentaaed404db2384bd1482df7492627e4738494c6a9 (diff)
Fix resource leak on dir_topology, dir not being closed
Valgrind found the following leak: ==8065== 131,264 bytes in 4 blocks are definitely lost in loss record 11 of 11 ==8065== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==8065== by 0x4EF4C10: __alloc_dir (opendir.c:207) ==8065== by 0x4053D2: topo_folder_scan (topology.c:308) ==8065== by 0x405510: read_sysfs_cpu_topo (topology.c:344) ==8065== by 0x404630: main (idlestat.c:1250) dir_topology should be closed to stop this leak. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
-rw-r--r--topology.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/topology.c b/topology.c
index d549e13..2b45adc 100644
--- a/topology.c
+++ b/topology.c
@@ -308,6 +308,7 @@ static int topo_folder_scan(char *path, folder_filter_t filter)
dir_topology = opendir(path);
if (!dir_topology)
continue;
+ closedir(dir_topology);
read_topology_cb(newpath, &cpu_info);
assert(sscanf(direntp->d_name, "cpu%d",