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 E01E0A0C40; Wed, 7 Apr 2021 19:08:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 599C9140EB7; Wed, 7 Apr 2021 19:08:53 +0200 (CEST) Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) by mails.dpdk.org (Postfix) with ESMTP id 578A6140EB2 for ; Wed, 7 Apr 2021 19:08:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1617815328; cv=none; d=zohomail.eu; s=zohoarc; b=eAhb/V4fA4spbTiL7jBnBr94m9waZByKNeaRVrxUsDjLLim6y6rTQkli4WuxDN0+ijYcwx9a4uGCH7Y2WQpq+4DgzHs5SeRJvrJX7c/go5L0gx2BQvQ1hfVyXO+DcChzJzWQTKVyLS2mi6oEvPbe1Vam1gsjPzmcUHLa3joAv9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1617815328; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=c5aC0KCJeyIEpMTmHyzK7NyGtS+XHnpwZIlKHAv35uE=; b=J/PpZq7OgD8KtidfnF8ukOhi3Qm5ryLB/luiOv7aWOAaLSPzjUHAQqiuz5/d/qB5QYhhKLtB5hyQU2czWDlxhUS63XceAmYF0vgNr2QnU0AawQMLcnK659Z7LkUsUjkeZjOPHtHas7OyFj0S9YXduTN+7nkMND8vuD5W6iDmZvE= ARC-Authentication-Results: i=1; mx.zohomail.eu; spf=pass smtp.mailfrom=liangma@liangbit.com; dmarc=pass header.from= header.from= Received: from C02F33EJML85 (47.254.128.112 [47.254.128.112]) by mx.zoho.eu with SMTPS id 1617815325631619.9415905950707; Wed, 7 Apr 2021 19:08:45 +0200 (CEST) Date: Wed, 7 Apr 2021 18:08:31 +0100 From: Liang Ma To: "Burakov, Anatoly" Cc: dev@dpdk.org, david.hunt@intel.com, thomas@monjalon.net Message-ID: References: <20210407155642.435964-1-anatoly.burakov@intel.com> <2602df98-aeb0-5513-2d4b-9c2cf242c3cd@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-ZohoMailClient: External 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 Wed, Apr 07, 2021 at 05:53:48PM +0100, Burakov, Anatoly wrote: > 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. > > >=20 > > > Coverity issue: 369901 > > >=20 > > > Fixes: 8a5febaac4f7 ("power: fix P-state base frequency handling") > > >=20 > > > Signed-off-by: Anatoly Burakov > > > --- > >=20 > > Actually, self-nack, because this: > >=20 > > =A0=A0=A0=A0snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE= _MIN_FREQ, > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 pi->lcore_id); > > =A0=A0=A0=A0f_min =3D fopen(fullpath_min, "rw+"); > > =A0=A0=A0=A0FOPEN_OR_ERR_RET(f_min, -1); > >=20 > > =A0=A0=A0=A0snprintf(fullpath_max, sizeof(fullpath_max), POWER_SYSFILE= _MAX_FREQ, > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 pi->lcore_id); > > =A0=A0=A0=A0f_max =3D fopen(fullpath_max, "rw+"); > > =A0=A0=A0=A0if (f_max =3D=3D NULL) > > =A0=A0=A0=A0=A0=A0=A0 fclose(f_min); > > =A0=A0=A0=A0FOPEN_OR_ERR_RET(f_max, -1); > >=20 > > comes after, and will leak the f_base descriptor. Closing it and settin= g > > it to NULL seems like a better solution. > >=20 >=20 > Actually no, scratch that, it doesn't :) that's before. So, patch should = be > OK. A Cup Coffee will help ;-)=20 >=20 > --=20 > Thanks, > Anatoly