I reviewed the libcgroup code in the viewpoint of memory-leak and
found some lacks of fclose(). This patch adds some fclose() calls
for error handling.
Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
temp_ent = (struct mntent *) malloc(sizeof(struct mntent));
if (!temp_ent) {
/* We just fail at the moment. */
+ fclose(proc_mount);
return 0;
}
ent = getmntent_r(proc_mount, temp_ent, mntent_buff,
sizeof(mntent_buff));
- if (!ent)
- return 0;
+ if (!ent) {
+ ret = 0;
+ goto done;
+ }
while (strcmp(ent->mnt_type, "cgroup") !=0) {
ent = getmntent_r(proc_mount, temp_ent, mntent_buff,
if (yyparse() != 0) {
cgroup_dbg("Failed to parse file %s\n", pathname);
+ fclose(yyin);
return ECGROUPPARSEFAIL;
}
(int *)&euid, (int *)&suid, (int *)&fsuid);
cgroup_dbg("Scanned proc values are %d %d %d %d\n",
ruid, euid, suid, fsuid);
+ fclose(fp);
return euid;
}
}
+ fclose(fp);
/* If we are here, we could not find euid. Return error. */
return -1;