Skip to content

Commit 3bc3d30

Browse files
praritandy-shev
authored andcommitted
tools/power/x86/intel-speed-select: Fix memory leak
cpumasks are allocated by calling the alloc_cpu_mask() function and are never free'd. They should be free'd after the commands have run. Fix the memory leaks by calling free_cpu_set(). Signed-off-by: Prarit Bhargava <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Cc: Srinivas Pandruvada <[email protected]> Cc: David Arcari <[email protected]> Cc: [email protected] Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 522586a commit 3bc3d30

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tools/power/x86/intel-speed-select/isst-config.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,10 @@ static int isst_fill_platform_info(void)
603603

604604
close(fd);
605605

606+
if (isst_platform_info.api_version > supported_api_ver) {
607+
printf("Incompatible API versions; Upgrade of tool is required\n");
608+
return -1;
609+
}
606610
return 0;
607611
}
608612

@@ -1528,6 +1532,7 @@ static void cmdline(int argc, char **argv)
15281532
{
15291533
int opt;
15301534
int option_index = 0;
1535+
int ret;
15311536

15321537
static struct option long_options[] = {
15331538
{ "cpu", required_argument, 0, 'c' },
@@ -1589,13 +1594,14 @@ static void cmdline(int argc, char **argv)
15891594
set_max_cpu_num();
15901595
set_cpu_present_cpu_mask();
15911596
set_cpu_target_cpu_mask();
1592-
isst_fill_platform_info();
1593-
if (isst_platform_info.api_version > supported_api_ver) {
1594-
printf("Incompatible API versions; Upgrade of tool is required\n");
1595-
exit(0);
1596-
}
1597+
ret = isst_fill_platform_info();
1598+
if (ret)
1599+
goto out;
15971600

15981601
process_command(argc, argv);
1602+
out:
1603+
free_cpu_set(present_cpumask);
1604+
free_cpu_set(target_cpumask);
15991605
}
16001606

16011607
int main(int argc, char **argv)

0 commit comments

Comments
 (0)