Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num()

In function get_pkg_num() if fopen_or_die() succeeds it returns a file
pointer to be used. But fclose() is never called before returning from
the function.

Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Samasth Norway Ananda and committed by
Rafael J. Wysocki
f85450f1 b401b621

+1
+1
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
··· 1241 1241 retval = fscanf(fp, "%d\n", &pkg); 1242 1242 if (retval != 1) 1243 1243 errx(1, "%s: failed to parse", pathname); 1244 + fclose(fp); 1244 1245 return pkg; 1245 1246 } 1246 1247