From c15dd044705aa86f63b2642c1439d5f943a80d18 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 20 Aug 2014 14:11:13 -0700 Subject: processgroup: close directories opened by removeAllProcessGroups() removeAllProcessGroups and removeUidProcessGroups were calling opendir, but never called closedir. This would leave a leaked file descriptor for every /acct/uid_* directory that existed at boot. Change-Id: Ia08eccd42d6ad7a6c1c78402519ac2e53b4fc83a --- libprocessgroup/processgroup.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libprocessgroup') diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp index c32e741..f7bc2cd 100644 --- a/libprocessgroup/processgroup.cpp +++ b/libprocessgroup/processgroup.cpp @@ -171,6 +171,7 @@ static void removeUidProcessGroups(const char *uid_path) SLOGV("removing %s\n", path); rmdir(path); } + closedir(uid); } } @@ -180,8 +181,7 @@ void removeAllProcessGroups() DIR *root = opendir(PROCESSGROUP_CGROUP_PATH); if (root == NULL) { SLOGE("failed to open %s: %s", PROCESSGROUP_CGROUP_PATH, strerror(errno)); - } - if (root != NULL) { + } else { struct dirent cur; struct dirent *dir; while ((readdir_r(root, &cur, &dir) == 0) && dir) { @@ -199,6 +199,7 @@ void removeAllProcessGroups() SLOGV("removing %s\n", path); rmdir(path); } + closedir(root); } } -- cgit v1.1