mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-06 05:06:29 +00:00
tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num()
[ Upstream commit f85450f134
]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
635594cca5
commit
51a9b20a04
@ -1241,6 +1241,7 @@ unsigned int get_pkg_num(int cpu)
|
|||||||
retval = fscanf(fp, "%d\n", &pkg);
|
retval = fscanf(fp, "%d\n", &pkg);
|
||||||
if (retval != 1)
|
if (retval != 1)
|
||||||
errx(1, "%s: failed to parse", pathname);
|
errx(1, "%s: failed to parse", pathname);
|
||||||
|
fclose(fp);
|
||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user