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 <prarit@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: David Arcari <darcari@redhat.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
Prarit Bhargava 2019-09-05 08:03:11 -04:00 committed by Andy Shevchenko
parent 522586a9d5
commit 3bc3d30ca3
1 changed files with 11 additions and 5 deletions

View File

@ -603,6 +603,10 @@ static int isst_fill_platform_info(void)
close(fd); close(fd);
if (isst_platform_info.api_version > supported_api_ver) {
printf("Incompatible API versions; Upgrade of tool is required\n");
return -1;
}
return 0; return 0;
} }
@ -1528,6 +1532,7 @@ static void cmdline(int argc, char **argv)
{ {
int opt; int opt;
int option_index = 0; int option_index = 0;
int ret;
static struct option long_options[] = { static struct option long_options[] = {
{ "cpu", required_argument, 0, 'c' }, { "cpu", required_argument, 0, 'c' },
@ -1589,13 +1594,14 @@ static void cmdline(int argc, char **argv)
set_max_cpu_num(); set_max_cpu_num();
set_cpu_present_cpu_mask(); set_cpu_present_cpu_mask();
set_cpu_target_cpu_mask(); set_cpu_target_cpu_mask();
isst_fill_platform_info(); ret = isst_fill_platform_info();
if (isst_platform_info.api_version > supported_api_ver) { if (ret)
printf("Incompatible API versions; Upgrade of tool is required\n"); goto out;
exit(0);
}
process_command(argc, argv); process_command(argc, argv);
out:
free_cpu_set(present_cpumask);
free_cpu_set(target_cpumask);
} }
int main(int argc, char **argv) int main(int argc, char **argv)