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 BE710A0C43; Wed, 7 Apr 2021 18:31:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EC26140EE8; Wed, 7 Apr 2021 18:31:11 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 20775140ED1 for ; Wed, 7 Apr 2021 18:31:09 +0200 (CEST) IronPort-SDR: 6VMw+Il9xLyVEe85QAqNjdUUTiJRA2o9AGPuUCPF3qmx4rWhMPjPwSoBj+DA6iir26qUosop1J CLWXgoXF5/fw== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="257334911" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="257334911" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 09:31:09 -0700 IronPort-SDR: HtLhbaZlhujhD7n2RpPS7JSaeY/GMUhJewqhz9HHk8X5SQuskCFeWjEHstzPn4/fOTqKGZZskE ht8lvjdOcUaQ== X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="530266337" 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:31:07 -0700 From: "Burakov, Anatoly" To: dev@dpdk.org Cc: david.hunt@intel.com, thomas@monjalon.net References: <20210407155642.435964-1-anatoly.burakov@intel.com> Message-ID: <2602df98-aeb0-5513-2d4b-9c2cf242c3cd@intel.com> Date: Wed, 7 Apr 2021 17:31:06 +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-Language: en-US Content-Transfer-Encoding: 7bit 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 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. -- Thanks, Anatoly