tools/power/x86/intel-speed-select: Fix file descriptor leak in isolate_cpus()
Subsystems (2)
PATCH 1/1 tools/power/x86/intel-speed-select: Fix file descriptor leak in isolate_cpus()
The file descriptor opened in isolate_cpus() when (!level) is true was not being closed before returning, causing a file descriptor leak in both the error path and the success path.
When write() fails at line 950, the function returns at line 953 without closing the file descriptor. Similarly, on success, the function returns at line 956 without closing the file descriptor.
Add close(fd) calls before both return statements to fix the resource leak. This follows the same pattern used elsewhere in the same function where file descriptors are properly closed before returning (see lines 1005 and 1027).
--- tools/power/x86/intel-speed-select/isst-config.c | 2 ++ 1 file changed, 2 insertions(+)
tools/power/x86/intel-speed-select/isst-config.c +2 -0
@@ -950,9 +950,11 @@ int isolate_cpus(struct isst_id *id, int mask_size, cpu_set_t *cpu_mask, int lev ret =write (fd,"member" ,strlen ("member" ));if (ret ==-1 ) {printf ("Can't update to member\n" ); +close (fd);return ret; } +close (fd);return 0 ; }
Signature · 1 line
2.52.0
srinivas pandruvada
maintainerQuoted 18 lines · Malaya Kumar Rout
The file descriptor opened in
isolate_cpus()when (!level) is true was
not being closed before returning, causing a file descriptor leak in both the error path and the success path.When
write()fails at line 950, the function returns at line 953 without
closing the file descriptor. Similarly, on success, the function returns
at line 956 without closing the file descriptor.Add close(fd) calls before both return statements to fix the resource leak. This follows the same pattern used elsewhere in the same function
where file descriptors are properly closed before returning (see lines
1005 and 1027).
Quoted 2 lines
Fixes 997074df658e ("tools/power/x86/intel-speed-select: Use cgroupv2 isolation")
Thanks for the change. Will include in the next pull request.
-Srinivas
Quoted 23 lines
Signed-off-by Malaya Kumar Rout <[email protected]>---
tools/power/x86/intel-speed-select/isst-config.c | 2 ++1 file changed, 2 insertions(+)tools/power/x86/intel-speed-select/isst-config.c +0
-0@@ -950,9 +950,11 @@ int isolate_cpus(struct isst_id *id, int
mask_size,cpu_set_t*cpu_mask, int lev
ret =write(fd, "member", strlen("member")); if (ret == -1) {
printf("Can't update to member\n");tools/power/x86/intel-speed-select/isst-config.c +1
-0+close (fd);return ret;
}tools/power/x86/intel-speed-select/isst-config.c +1
-0+close (fd);return 0;
}