Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp414939ybe; Fri, 6 Sep 2019 01:18:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKJ04x/wLfGvqUWDUmtqH7X1t/gOas7QWqGsPPwYJFy/CeWR4Z+ZZYwR1MyXPrSw6+yKSG X-Received: by 2002:aa7:919a:: with SMTP id x26mr8508970pfa.58.1567757930320; Fri, 06 Sep 2019 01:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567757930; cv=none; d=google.com; s=arc-20160816; b=bWSlVIZppIddP+Gi+EIL2pFyo1LctW8wl58J7I/lIKOJfzkPXDLRercVF9Zgq5XAvs KMcJa1LBAjkw60IPEIDcAUoa9T6OeyurIr8D75y1r61jlnJnatCcIMyZ1rpwW5/QUVBU vo85uadrZJvRAWrybbBVRf2DDb323x029ykgoshnwi0aKkZ+Usqr+CT52gSIUTZrTgV0 14SAhZxfMTW4gGjNdToDOrR6O0oYE5Snw5+7LHMRcqGfYfw0Ar/t1cWRljHs2X1vDqt1 ya1oRxNPGNZ8MkmobvJCLpqqtePLdD6baZThgzlHkL2pO85JBDN4yVOiuV6UUhH3Kovl Ozgw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=o3cpctgPT5TvBcasng3A/UqYxI3n76ZbSFZcvVWiLp8=; b=M4zJzGm1zQ6VhRpcSuXK/dkhePxt9GP+pr7yCKesWeamsMTqBw7kTua26OwthzZCeK r8BFW/uikCtPft5zpVulKomHzcMYvg4Mx6jGUMozE6C8g6YPeQHrX6DGepuOuQ5SyWHP G+q9AlD7asyJS+rjUEHYanGJQjDIWYpQr/qKycp56eHbYIwKcHnSZOeMIHBF5xiLRjTu 0QRBbGZGLPLcD4hqnr+p2y3hRiyhJ9V/IGPJeI5BO+pFL6GEnEOcbP5usLSEybWDMyvv nv+C4xVywSj6wGvtSKTmbuDJOlohX1CfE6CcSkM6RTLsNJMte0+CL0QAKXwqSf2aj/Ly BvrQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 126si3790180pfx.172.2019.09.06.01.18.34; Fri, 06 Sep 2019 01:18:50 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389401AbfIEVAP (ORCPT + 99 others); Thu, 5 Sep 2019 17:00:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38380 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726936AbfIEVAO (ORCPT ); Thu, 5 Sep 2019 17:00:14 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50D4C30083ED; Thu, 5 Sep 2019 21:00:14 +0000 (UTC) Received: from prarit.bos.redhat.com (prarit-guest.khw1.lab.eng.bos.redhat.com [10.16.200.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1C1C60610; Thu, 5 Sep 2019 21:00:13 +0000 (UTC) Subject: Re: [PATCH v2 9/9] tools/power/x86/intel-speed-select: Fix memory leak To: Srinivas Pandruvada , platform-driver-x86@vger.kernel.org Cc: andriy.shevchenko@intel.com, David Arcari , linux-kernel@vger.kernel.org References: <20190905120311.15286-1-prarit@redhat.com> <20190905120311.15286-10-prarit@redhat.com> From: Prarit Bhargava Message-ID: <13983f13-098e-4390-c014-43b59c4e2f27@redhat.com> Date: Thu, 5 Sep 2019 17:00:13 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 05 Sep 2019 21:00:14 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/5/19 3:42 PM, Srinivas Pandruvada wrote: > 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. > I'm sorry, I misunderstood your comment. Yes, the process will exit after one command :) P. > 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) >