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 A41EFA0A0C; Wed, 7 Apr 2021 18:53:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D6A3140EA4; Wed, 7 Apr 2021 18:53:56 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 6381D140E19 for ; Wed, 7 Apr 2021 18:53:54 +0200 (CEST) IronPort-SDR: vac5dCspCb3XMo0Ig3sDI9ku2iGJKldsKVBbjjnb9oaHQJbK6nERT4EU/HQUnOSnQjcrykGC7c vVsBMT8lxt8w== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="180484351" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="180484351" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 09:53:53 -0700 IronPort-SDR: vkRhyzbq6EAlLeC7Cxb1tbC4QGBFWjfe8Ml+Nr9DdVtCuebyX9mid+pJGhoSY2ndST7t/nFXP/ iMCM65eETRCA== X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="530272791" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.213.215.35]) ([10.213.215.35]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 09:53:52 -0700 From: "Burakov, Anatoly" To: dev@dpdk.org Cc: david.hunt@intel.com, thomas@monjalon.net References: <20210407155642.435964-1-anatoly.burakov@intel.com> <2602df98-aeb0-5513-2d4b-9c2cf242c3cd@intel.com> Message-ID: Date: Wed, 7 Apr 2021 17:53:48 +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: <2602df98-aeb0-5513-2d4b-9c2cf242c3cd@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit 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" On 07-Apr-21 5:31 PM, Burakov, Anatoly wrote: > On 07-Apr-21 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 >> --- > > Actually, self-nack, because this: > >     snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ, >             pi->lcore_id); >     f_min = fopen(fullpath_min, "rw+"); >     FOPEN_OR_ERR_RET(f_min, -1); > >     snprintf(fullpath_max, sizeof(fullpath_max), POWER_SYSFILE_MAX_FREQ, >             pi->lcore_id); >     f_max = fopen(fullpath_max, "rw+"); >     if (f_max == NULL) >         fclose(f_min); >     FOPEN_OR_ERR_RET(f_max, -1); > > comes after, and will leak the f_base descriptor. Closing it and setting > it to NULL seems like a better solution. > Actually no, scratch that, it doesn't :) that's before. So, patch should be OK. -- Thanks, Anatoly