Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1455536ybe; Thu, 5 Sep 2019 16:03:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwv3bD8yowMqtzPl1lsu3G8qs0gKCPwO4djgN+tkoTKHRA1GC0PaD5LThh7YuOpnnJxgBUo X-Received: by 2002:a17:902:4283:: with SMTP id h3mr6434680pld.56.1567724580548; Thu, 05 Sep 2019 16:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567724580; cv=none; d=google.com; s=arc-20160816; b=cYSQrBYD4HKBrhb/CVyco1EIUYvgZ69AcNDQQ37xujgBzDNmsy80NpWPLzKpiX4xsN I4yeLrf0keT2RZlWY7FUgex3Y6HW2dvmLHReBtLYCDlhVDvnkSLVVHO72iNYoR+M2/Xx o9RhwGOz1B3OsGbo03XD692vTBlzqbrz/guicxQtFhAhIz95gpvPXFsAuwwVgzvi86qP YLC+ZxIK7PaVQwoJqxPtpnE+BXe7pX9L80PyPnUCv8uRpqHvYgtDIWWkbRtfyHB77HxL 0RZGWmHztyHlwIm6jLtxN9ewM00pmHJcdUzl0xQZrsxcGknw7LtYZ6DEQf6iYDwqXHvw DvQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=EslwDUsv0sxpqwRtFxSeYDou20SQ+gfnkaxGrEuOess=; b=p7uo2wOqJnymZqjXogPh19ezRkBzwhT4ayyOtIrVUptqKnZMkh4fIPy6L+zY8k10hI qXrbU65vVy3pWWo7DhRRgwSQ495J5N6OE5IcHcJVjRl+PWTcvfCjrvFqKWuRkW+9xBGL rsGkvb9N1NISBRNTvHdGxlQeYFR/EKKujKHrCwpTQ/+sr5IbziLHUjWoNz0nFGgP1rpH txIOyilk+VMhJ1OTN5+5NSknhOuJt/vgUrou1wiNU5uePlUmCY6ETEaB+qHXjdl7xv+B Ndx8LNpjKyB/vu7VuOXgV5IgT5hCmmSHqLPPPEceo1U0kcwFI9ku+ulTDPxkWSSDV4zK vceg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z199si3281649pfc.283.2019.09.05.16.02.39; Thu, 05 Sep 2019 16:03:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390023AbfIETmG (ORCPT + 99 others); Thu, 5 Sep 2019 15:42:06 -0400 Received: from mga06.intel.com ([134.134.136.31]:40846 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbfIETmG (ORCPT ); Thu, 5 Sep 2019 15:42:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2019 12:42:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,471,1559545200"; d="scan'208";a="182924968" Received: from mlamm-mobl1.amr.corp.intel.com (HELO spandruv-mobl3.jf.intel.com) ([10.251.22.142]) by fmsmga008.fm.intel.com with ESMTP; 05 Sep 2019 12:42:05 -0700 Message-ID: Subject: Re: [PATCH v2 9/9] tools/power/x86/intel-speed-select: Fix memory leak From: Srinivas Pandruvada To: Prarit Bhargava , platform-driver-x86@vger.kernel.org Cc: andriy.shevchenko@intel.com, David Arcari , linux-kernel@vger.kernel.org Date: Thu, 05 Sep 2019 12:42:05 -0700 In-Reply-To: <20190905120311.15286-10-prarit@redhat.com> References: <20190905120311.15286-1-prarit@redhat.com> <20190905120311.15286-10-prarit@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-3.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-09-05 at 08:03 -0400, Prarit Bhargava wrote: > 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(). Good to fix this. But after one command execution the process will exit. Thanks, Srinivas > > Signed-off-by: Prarit Bhargava > Cc: Srinivas Pandruvada > Cc: David Arcari > Cc: linux-kernel@vger.kernel.org > --- > tools/power/x86/intel-speed-select/isst-config.c | 16 +++++++++++--- > -- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/tools/power/x86/intel-speed-select/isst-config.c > b/tools/power/x86/intel-speed-select/isst-config.c > index 78f0cebda1da..59753b3917bb 100644 > --- a/tools/power/x86/intel-speed-select/isst-config.c > +++ b/tools/power/x86/intel-speed-select/isst-config.c > @@ -603,6 +603,10 @@ static int isst_fill_platform_info(void) > > 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; > } > > @@ -1528,6 +1532,7 @@ static void cmdline(int argc, char **argv) > { > int opt; > int option_index = 0; > + int ret; > > static struct option long_options[] = { > { "cpu", required_argument, 0, 'c' }, > @@ -1589,13 +1594,14 @@ static void cmdline(int argc, char **argv) > set_max_cpu_num(); > set_cpu_present_cpu_mask(); > set_cpu_target_cpu_mask(); > - isst_fill_platform_info(); > - if (isst_platform_info.api_version > supported_api_ver) { > - printf("Incompatible API versions; Upgrade of tool is > required\n"); > - exit(0); > - } > + ret = isst_fill_platform_info(); > + if (ret) > + goto out; > > process_command(argc, argv); > +out: > + free_cpu_set(present_cpumask); > + free_cpu_set(target_cpumask); > } > > int main(int argc, char **argv)