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 30070A0548; Thu, 1 Apr 2021 17:05:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C6BD14136B; Thu, 1 Apr 2021 17:05:17 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 61125140EE8 for ; Thu, 1 Apr 2021 17:05:15 +0200 (CEST) IronPort-SDR: Hv3Vf4eN+qyKTrMzSYLR+tQ+WVYuYuAe3IIvbvyPPIr8uCNWgiGiZXOrJocOVbtxfJPJm7yT/a vWsHlexa1Ytw== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="191741119" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="191741119" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 08:05:02 -0700 IronPort-SDR: ZuJsFiXRmFYFFIFD6tqsPlsg26TZPyyit4c9Be8+blN2yMbf3vAEWJ6cVD1K6GAnYrNHU3DMlZ CRqrSi1dervQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208";a="419235786" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.97]) by orsmga008.jf.intel.com with ESMTP; 01 Apr 2021 08:05:00 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: anatoly.burakov@intel.com, david.hunt@intel.com Date: Thu, 1 Apr 2021 15:04:59 +0000 Message-Id: <20210401150500.234015-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 v2 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