From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8744EA0524; Tue, 13 Apr 2021 14:22:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1D69160EFD; Tue, 13 Apr 2021 14:22:12 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 645DA160EFC for ; Tue, 13 Apr 2021 14:22:11 +0200 (CEST) IronPort-SDR: Y17RwewwUOEAFIwyS/yU9aafPbO5Wjbe1SeGoJnZrq9y75GXpm79jZ54Jh3NcrcXrLGYGRO8J+ nLk2UhPngPBA== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="174499439" X-IronPort-AV: E=Sophos;i="5.82,219,1613462400"; d="scan'208";a="174499439" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 05:22:10 -0700 IronPort-SDR: 3Or/8ulYd7Uv3/dm155A6ReG3LVRvezCfYVlVzi4XLEh8vvQhNjApmcrtnIsKWDNHnvLEmyr4B YIy1sitzrwfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,219,1613462400"; d="scan'208";a="383294505" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.223.188]) by orsmga006.jf.intel.com with ESMTP; 13 Apr 2021 05:22:09 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: david.hunt@intel.com, reshma.pattan@intel.com Date: Tue, 13 Apr 2021 12:22:08 +0000 Message-Id: <20210413122208.101057-1-anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] power: fix resource leak X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, we open the system base frequency file, but never close it, which results in a memory leak. Coverity issue: 369693 Fixes: 8a5febaac4f7 ("power: fix P-state base frequency handling") Cc: david.hunt@intel.com Cc: reshma.pattan@intel.com Signed-off-by: Anatoly Burakov --- Notes: Ideally, the close should be added at the end, but there's a bunch of ERR_RET macros before that, so addressing that would put us dangerously close to refactoring, which is not what we want to do so close to the release. This issue was already "fixed", but because the variable naming and the flow of code is confusing, the fix was addressing a different variable. There is a patch for 21.08 that will address the code flow and make it less confusing. lib/librte_power/power_pstate_cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index ec745153d3..1451a024be 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -185,6 +185,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi) base_max_ratio = strtoul(buf_base, NULL, POWER_CONVERT_TO_DECIMAL) / BUS_FREQ; + /* not needed any more */ + fclose(f_base_max); + f_base_max = NULL; } snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ, -- 2.25.1