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 BE87EA0548; Thu, 1 Apr 2021 17:06:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A4BAE14116E; Thu, 1 Apr 2021 17:06:20 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 7D9D7140EE8 for ; Thu, 1 Apr 2021 17:06:18 +0200 (CEST) IronPort-SDR: qH5wx64G6VpYujbtUEox2ULnljEYxzgAuZf25m6iMovpe776Bt9q2zlAvDTBFG8v0b8qJ/USoC iU3xVeijGSQg== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="256247255" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="256247255" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 08:06:16 -0700 IronPort-SDR: G16hAkhFLIQk6HjSyb5IfUI8axbLFdk4l0qjOJrpJa4lVUZKp0Hu6zMaqeapg3/Ss4r0Y/rC6L 9tov07gmsEfg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="412722692" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.97]) by fmsmga008.fm.intel.com with ESMTP; 01 Apr 2021 08:06:15 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: anatoly.burakov@intel.com, david.hunt@intel.com Date: Thu, 1 Apr 2021 15:06:13 +0000 Message-Id: <20210401150614.234257-1-anatoly.burakov@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 1/2] power: fix pstate base frequency handling 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" Previous fix for base frequency handling in pstate mode introduced a couple of issues: - When base_frequency file does not exist, it simply bails out because of what appears to be accidental addition of FOPEN_OR_ERR_RET. This is incorrect, as absence of this file is not fatal and is in fact expected on kernel versions earlier than 5.3 - When base_frequency file does exist, it gets opened, but never gets closed, resulting in a resource leak Both issues also manifest themselves as Coverity defects (dead code, and a resource leak), so this fix addresses both. Fixes: 4db9587bbf72 ("power: check sysfs base frequency") Cc: david.hunt@intel.com Coverity issue: 369693 Coverity issue: 369694 Bugzilla ID: 668 Signed-off-by: Anatoly Burakov --- lib/librte_power/power_pstate_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 8a1fffaed5..af5ad0b506 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -172,7 +172,6 @@ power_init_for_setting_freq(struct pstate_power_info *pi) POWER_SYSFILE_BASE_MAX_FREQ, pi->lcore_id); f_base_max = fopen(fullpath_base_max, "r"); - FOPEN_OR_ERR_RET(f_base_max, -1); if (f_base_max != NULL) { s_base_max = fgets(buf_base, sizeof(buf_base), f_base_max); FOPS_OR_NULL_GOTO(s_base_max, out); @@ -185,6 +184,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) base_max_ratio = strtoul(buf_base, NULL, POWER_CONVERT_TO_DECIMAL) / BUS_FREQ; + fclose(f_base_max); } snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ, -- 2.25.1