| From 41493b969f3a91cd26b4e80266c83f846b23641b Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 15 Jan 2026 15:33:33 +0530 |
| Subject: tools/power/x86/intel-speed-select: Fix file descriptor leak in |
| isolate_cpus() |
| |
| From: Malaya Kumar Rout <mrout@redhat.com> |
| |
| [ Upstream commit 56c17ee151c6e1a73d77e15b82a8e2130cd8dd16 ] |
| |
| 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). |
| |
| Fixes: 997074df658e ("tools/power/x86/intel-speed-select: Use cgroup v2 isolation") |
| Signed-off-by: Malaya Kumar Rout <mrout@redhat.com> |
| Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| tools/power/x86/intel-speed-select/isst-config.c | 2 ++ |
| 1 file changed, 2 insertions(+) |
| |
| diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c |
| index 558138eea75e9..d00d15490a98c 100644 |
| --- a/tools/power/x86/intel-speed-select/isst-config.c |
| +++ b/tools/power/x86/intel-speed-select/isst-config.c |
| @@ -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; |
| } |
| |
| -- |
| 2.51.0 |
| |