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 96B63A0C40; Wed, 7 Apr 2021 18:11:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7CC78140F37; Wed, 7 Apr 2021 18:11:01 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id EF57D140F23 for ; Wed, 7 Apr 2021 18:10:59 +0200 (CEST) IronPort-SDR: wleULBlgftIiKExVN8h3FOW2voFN7u7d0jJG5Pi38CxmJzgPaknbveBNWALvYcPVAnSQajpdYw zcK+4X8MviIA== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="193386186" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="193386186" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 09:10:58 -0700 IronPort-SDR: 7z7Y5t0mZ6MP71C209wfGDfFnjZqu2wX3fppdpqourdurel9JcyzV8MDQUFZ0v311QrCqd74tO 5oT1TwuW9owg== X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="458430156" Received: from dhunt5-mobl5.ger.corp.intel.com (HELO [10.252.16.119]) ([10.252.16.119]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 09:10:54 -0700 To: Anatoly Burakov , dev@dpdk.org Cc: thomas@monjalon.net References: <20210407155642.435964-1-anatoly.burakov@intel.com> From: David Hunt Message-ID: <572691ce-b0c1-d13c-1315-ea7600e1ad24@intel.com> Date: Wed, 7 Apr 2021 17:10:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210407155642.435964-1-anatoly.burakov@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [dpdk-dev] [PATCH] power: fix use-after-free in pstate code 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" Hi Anatoly, On 7/4/2021 4:56 PM, Anatoly Burakov wrote: > Previous fix has addressed the incorrect handling of `base_frequency` > file, but has added a use-after-free error due to the fact that all > further code paths will lead to an `fclose()` call at the end, so the > additional `fclose()` call right after processing the file was > unnecessary. > > Coverity issue: 369901 > > Fixes: 8a5febaac4f7 ("power: fix P-state base frequency handling") > > Signed-off-by: Anatoly Burakov > --- > lib/librte_power/power_pstate_cpufreq.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c > index 1cb0e4d917..ec745153d3 100644 > --- a/lib/librte_power/power_pstate_cpufreq.c > +++ b/lib/librte_power/power_pstate_cpufreq.c > @@ -220,7 +220,6 @@ power_init_for_setting_freq(struct pstate_power_info *pi) > > base_ratio = strtoul(buf_base, NULL, POWER_CONVERT_TO_DECIMAL) > / BUS_FREQ; > - fclose(f_base); > } > > /* Add MSR read to detect turbo status */ Yes, removing the fclose will do it. Either that or add an "f_base = NULL" after the fclose, but the fclose removal is fine. Acked-by: David Hunt