From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id BD0125F17 for ; Tue, 15 Jan 2019 11:01:52 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2019 02:01:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,481,1539673200"; d="scan'208";a="126166668" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by orsmga002.jf.intel.com with ESMTP; 15 Jan 2019 02:01:50 -0800 From: David Hunt To: dev@dpdk.org Cc: liang.j.ma@intel.com, lei.a.yao@intel.com, David Hunt Date: Tue, 15 Jan 2019 10:01:37 +0000 Message-Id: <20190115100137.47470-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <1545996779-4098-1-git-send-email-liang.j.ma@intel.com> References: <1545996779-4098-1-git-send-email-liang.j.ma@intel.com> Subject: [dpdk-dev] [PATCH] libs/power: fix the resource leaking issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2019 10:01:53 -0000 From: Liang Ma Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility") Coverity issue: 328528 v2: focus just on the resource leak. Remove additional code around Turbo Boost frequency handling. Signed-off-by: Liang Ma Reviewed-by: Lei Yao Tested-by: Lei Yao Signed-off-by: David Hunt --- lib/librte_power/power_pstate_cpufreq.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index c4d972fc0..079822bf7 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -160,6 +160,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi) pi->lcore_id); f_max = fopen(fullpath_max, "rw+"); + + if (f_max == NULL) + fclose(f_min); + FOPEN_OR_ERR_RET(f_max, -1); pi->f_cur_min = f_min; @@ -398,6 +402,10 @@ power_get_available_freqs(struct pstate_power_info *pi) FOPEN_OR_ERR_RET(f_min, ret); f_max = fopen(fullpath_max, "r"); + + if (f_max == NULL) + fclose(f_min); + FOPEN_OR_ERR_RET(f_max, ret); s_min = fgets(buf_min, sizeof(buf_min), f_min); -- 2.17.1