From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 3C7FA2BCE for ; Mon, 8 Apr 2019 18:19:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2019 09:19:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,325,1549958400"; d="scan'208";a="334886863" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga006.fm.intel.com with ESMTP; 08 Apr 2019 09:19:19 -0700 Received: from sivswdev09.ir.intel.com (sivswdev09.ir.intel.com [10.237.217.48]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x38GJJp8021848; Mon, 8 Apr 2019 17:19:19 +0100 Received: from sivswdev09.ir.intel.com (localhost [127.0.0.1]) by sivswdev09.ir.intel.com with ESMTP id x38GJJqQ013970; Mon, 8 Apr 2019 17:19:19 +0100 Received: (from lma25@localhost) by sivswdev09.ir.intel.com with LOCAL id x38GJI7T013966; Mon, 8 Apr 2019 17:19:18 +0100 From: Liang Ma To: dev@dpdk.org Cc: david.hunt@intel.com, anatoly.burakov@intel.com, Liang Ma Date: Mon, 8 Apr 2019 17:19:16 +0100 Message-Id: <1554740356-13914-1-git-send-email-liang.j.ma@intel.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1554736884-12195-1-git-send-email-liang.j.ma@intel.com> References: <1554736884-12195-1-git-send-email-liang.j.ma@intel.com> Subject: [dpdk-dev] [PATCH v2] power: fix coverity 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: Mon, 08 Apr 2019 16:19:23 -0000 Fix the resource leaking issue Coverity issue: 337668 Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores") Signed-off-by: Liang Ma --- lib/librte_power/power_pstate_cpufreq.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 336c13869..07ca5c1dd 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -158,6 +158,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) char *s_base; uint32_t base_ratio = 0; uint64_t max_non_turbo = 0; + int ret_val = 0; snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ, pi->lcore_id); @@ -199,8 +200,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi) /* Add MSR read to detect turbo status */ - if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) - return -1; + if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) { + ret_val = -1; + goto out; + } max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET; @@ -219,7 +222,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi) pi->core_base_freq = base_ratio * BUS_FREQ; out: - return 0; + if (f_base != NULL) + fclose(f_base); + return ret_val; } static int -- 2.17.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E6462A0096 for ; Mon, 8 Apr 2019 18:19:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 825072C24; Mon, 8 Apr 2019 18:19:23 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 3C7FA2BCE for ; Mon, 8 Apr 2019 18:19:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2019 09:19:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,325,1549958400"; d="scan'208";a="334886863" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga006.fm.intel.com with ESMTP; 08 Apr 2019 09:19:19 -0700 Received: from sivswdev09.ir.intel.com (sivswdev09.ir.intel.com [10.237.217.48]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id x38GJJp8021848; Mon, 8 Apr 2019 17:19:19 +0100 Received: from sivswdev09.ir.intel.com (localhost [127.0.0.1]) by sivswdev09.ir.intel.com with ESMTP id x38GJJqQ013970; Mon, 8 Apr 2019 17:19:19 +0100 Received: (from lma25@localhost) by sivswdev09.ir.intel.com with LOCAL id x38GJI7T013966; Mon, 8 Apr 2019 17:19:18 +0100 From: Liang Ma To: dev@dpdk.org Cc: david.hunt@intel.com, anatoly.burakov@intel.com, Liang Ma Date: Mon, 8 Apr 2019 17:19:16 +0100 Message-Id: <1554740356-13914-1-git-send-email-liang.j.ma@intel.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1554736884-12195-1-git-send-email-liang.j.ma@intel.com> References: <1554736884-12195-1-git-send-email-liang.j.ma@intel.com> Subject: [dpdk-dev] [PATCH v2] power: fix coverity 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190408161916.gVn6wqS3wsto8n_GH8uZD_YdBJUnfj_W0m1p4vozu-0@z> Fix the resource leaking issue Coverity issue: 337668 Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores") Signed-off-by: Liang Ma --- lib/librte_power/power_pstate_cpufreq.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 336c13869..07ca5c1dd 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -158,6 +158,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi) char *s_base; uint32_t base_ratio = 0; uint64_t max_non_turbo = 0; + int ret_val = 0; snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ, pi->lcore_id); @@ -199,8 +200,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi) /* Add MSR read to detect turbo status */ - if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) - return -1; + if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) { + ret_val = -1; + goto out; + } max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET; @@ -219,7 +222,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi) pi->core_base_freq = base_ratio * BUS_FREQ; out: - return 0; + if (f_base != NULL) + fclose(f_base); + return ret_val; } static int -- 2.17.2