Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp666705pxb; Fri, 14 Jan 2022 13:33:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJya8NbKkPq32c1aBR8OQTo1Bhe8Xl7qf08SObinoEknvt2SALiFOf3dvc05ZfWxq8V28k4y X-Received: by 2002:a17:902:7209:b0:149:64f4:b8a1 with SMTP id ba9-20020a170902720900b0014964f4b8a1mr11690031plb.0.1642196038655; Fri, 14 Jan 2022 13:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642196038; cv=none; d=google.com; s=arc-20160816; b=b/mNIexoKFB0Rq9xsDoQIyFGyj9SP+Grek0ac0RciDo3BlGw9Y339yXk2JLsb1F/ka hvu74MJWTeI7Yt5JK7q6ns8I2pwvZ3iwG80wf5Tit/Y6r1BsaYJA4XRfJ6jJXgc2cXIn vP6nAQpsQWz2eZjcHeUV3Df5LwWqn7SQIMgOLDZRPEsotWP2UMO4hWE70hum2FWJd33R aDlEnuR59+Bk2/HCKUR8noDAn4fsGhNMX0DeHkep/pciwnWUo6x5MSd7KwvZPaykwl12 GJwvhELyO1zbEkN7fI68gY7oJ051SEIzjm9zjkXXJ5ZfyA6Pt+s2vOFxV6wj0HPfe8XZ aJcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=B5+pEyLBrTpX5tcsN5IIWp/zFMLqXLxVNRfG33SduFE=; b=UFdLDb6ATYUHA8weiixEwSpfqoeTfd1emFmtHG6J+GtlaYE/lkerqsLzwm20rEmTmY bnk5AUbIKU8gbLIqQCz57VT5FCgH3AXP1Yty3UxeuvsrTY6uNss5oTQOv94n62CW917U aUkmjY9HJlsEKWU2ke5wjBc+vBqEiv5aaPgaDAWAuxQFrfH7414CZhFUTUxUjMqN7hc5 0lAnJUr5a28AQsWisAvOaGfsIvUDwL+8QPNv24YyVfuqa9Z+PXhXfllhveaFhF41eEqg 5WPc1n/ALv3SSkVlai0OpsqC7/andWluwujpkcriOkIWJAkKd1fdE7buDH4QWOjCcZVG 7rig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XRmdGq+l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 28si7194345pgu.338.2022.01.14.13.33.46; Fri, 14 Jan 2022 13:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XRmdGq+l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242004AbiANOrt (ORCPT + 99 others); Fri, 14 Jan 2022 09:47:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233727AbiANOrs (ORCPT ); Fri, 14 Jan 2022 09:47:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B350CC061574; Fri, 14 Jan 2022 06:47:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7674CB821B8; Fri, 14 Jan 2022 14:47:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C2B1C36AE5; Fri, 14 Jan 2022 14:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642171664; bh=27uxthPRWS3BTbs9jsMyrj3qXiQA2+lLgqw7CVx3CBI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XRmdGq+lpq7UuP59DXn86gYzHIEWbvzbwl93c78/Nu+aAsZaEo5BvoL0PeDedAB/s VuaPIxWAQeIm3YK5+QaymzX3UjSrDGsOdV6G89zyRjM0jLJWqvWxe2Sg15ELaggaeF FNmEC2RTRbBAHwTCKu3ykt/i1Xz8U9H83731F1uO5oYYb7N5Mw9vCx93xeZoSOkjnY GowTykrtQ61Xmyef50CmQ32OONFKZoLtkLI5k6j3bMv0jCdQ7dozf4Cn2fSMBgvWna GoUvYKoAws3go5LYgr8RLgHMYAKo3W7QDhzqRQzmBUI8IeZz8JelBwCsDDhBQqAckr hqXUYjVHH8Cdw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CBB8240714; Fri, 14 Jan 2022 11:47:42 -0300 (-03) Date: Fri, 14 Jan 2022 11:47:42 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= , peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, ak@linux.intel.com, john.garry@huawei.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf util: Fix use after free in metric__new Message-ID: References: <20211208171113.22089-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Dec 08, 2021 at 09:33:14AM -0800, Ian Rogers escreveu: > On Wed, Dec 8, 2021 at 9:11 AM Jos? Exp?sito wrote: > > > > Addresses-Coverity-ID: 1494000 > > Signed-off-by: Jos? Exp?sito > > Acked-by: Ian Rogers > > This can only happen in the ENOMEM case, but it is a good fix. > > Fixes: b85a4d61d302 (perf metric: Allow modifiers on metrics) Sorry, I missed this one _as well_, sigh... - Arnaldo > Thanks, > Ian > > > --- > > tools/perf/util/metricgroup.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > > index fffe02aae3ed..4d2fed3aefd1 100644 > > --- a/tools/perf/util/metricgroup.c > > +++ b/tools/perf/util/metricgroup.c > > @@ -209,8 +209,8 @@ static struct metric *metric__new(const struct pmu_event *pe, > > m->metric_name = pe->metric_name; > > m->modifier = modifier ? strdup(modifier) : NULL; > > if (modifier && !m->modifier) { > > - free(m); > > expr__ctx_free(m->pctx); > > + free(m); > > return NULL; > > } > > m->metric_expr = pe->metric_expr; > > -- > > 2.25.1 > > -- - Arnaldo