Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3270611rwb; Mon, 15 Aug 2022 22:52:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR6aMMqgzkqMlMXRPz77ItCj34RjK9mRGFMuEvPI0kZlx0Q4LkRw7uB3DVFjMkP6KHp60ir/ X-Received: by 2002:a17:906:7622:b0:730:9a59:3892 with SMTP id c2-20020a170906762200b007309a593892mr11620123ejn.697.1660629135844; Mon, 15 Aug 2022 22:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660629135; cv=none; d=google.com; s=arc-20160816; b=XrtGHSUXGmQEaUTl08Nqrs5TqVlEZGrLiGzMqRslr3R7v+vFNaM+uGKb9SrOcyp+8S F0J087CuwfHWon9DkH2T869qd9itLKuTZNlJfq8r4OfNuVaTOlwlnIuJbspGua00nZZ6 sPt+CsQZ5Pih3gU5JpzAUuHFNrG30BYo3uhMq4zo/Usf2o8JNl+Uu4PVW1IcOgP2BSj0 2mDkMk5+7JRQ4/4eu79N6aUopQa39MPixUXx8Iv+uD7TunSH3xHsAdLM2+amep/zGbKZ ZYrPU2lqZrqCa2FT1SLSfRrQjM1qh+YXcp3kLnoYJYGGY0+Uz24oWR9Mda5gfT/26t1/ rgeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EgraQ6KoZf5dr4T7fOP3rgKLKZjHnrtiPfNpsWCAwvw=; b=xe6x5KgbjujXa/y5HjOOFFvkDoadoMF/fZ499IPkgNzM1zrfmjUvmkg21tgILTS4+5 iqQvDjSNYVKHMPQ9bH67dU9WsRGlRCZ1Fud87PTA4WAol3EMFvIVI0NDt3kd6UHvOxD1 wZC5iWmeEKvPkwduHkoEXOuihlke7yC06F2EAKWYNkiqY+/EynAB91zY+9rQApyZAp/a SvYVJnkQxLYX0MVYx1hGc2XUymdPjJ0Zfxd5ohpg9JIEnou9jxC7bdR3U1RzDiiV/SRW rTaEPKYXsRMGP+7jIVHdrwkHfqtCcKFQyp6Ei4gdxRuQVzOcGuE9cxPZOE2jupN7GXQN Gf6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MsOnGz4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eo12-20020a056402530c00b004409963eb80si8269231edb.432.2022.08.15.22.51.47; Mon, 15 Aug 2022 22:52:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MsOnGz4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbiHPEqj (ORCPT + 99 others); Tue, 16 Aug 2022 00:46:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbiHPEms (ORCPT ); Tue, 16 Aug 2022 00:42:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E76CABD6D; Mon, 15 Aug 2022 13:37:52 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 35F13611FC; Mon, 15 Aug 2022 20:37:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 293E0C43470; Mon, 15 Aug 2022 20:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595871; bh=WMHuwJF65OUTic2MXusj7pI//kwnDmHogdmjBJcNqpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MsOnGz4K64V/czgj9Dd1ZQUsq5FI5cDWZQRNI4yrpR8KxHm+sdYlMLsLC30RpwFez u0rIySwjhIbEdri2GPCSUKDNbm7fbfQSVp0JaW62ndlzvO8g8kAB/y+ntxtQCh+UOJ joDhOGyfDTwjDsWzoQxxhcthSVx6ItsW11J7I7y8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Schwab , Daniel Bristot de Oliveira , "Steven Rostedt (Google)" , Sasha Levin Subject: [PATCH 5.19 0869/1157] rtla: Fix double free Date: Mon, 15 Aug 2022 20:03:45 +0200 Message-Id: <20220815180514.237489066@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Schwab [ Upstream commit 4f753c3be52c1d930afc0fe3169baa605dbaf611 ] Avoid double free by making trace_instance_destroy indempotent. When trace_instance_init fails, it calls trace_instance_destroy, but its only caller osnoise_destroy_tool calls it again. Link: https://lkml.kernel.org/r/mvmilnlkyzx.fsf_-_@suse.de Fixes: 0605bf009f18 ("rtla: Add osnoise tool") Signed-off-by: Andreas Schwab Acked-by: Daniel Bristot de Oliveira Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- tools/tracing/rtla/src/trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index 5784c9f9e570..e1ba6d9f4265 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -134,13 +134,18 @@ void trace_instance_destroy(struct trace_instance *trace) if (trace->inst) { disable_tracer(trace->inst); destroy_instance(trace->inst); + trace->inst = NULL; } - if (trace->seq) + if (trace->seq) { free(trace->seq); + trace->seq = NULL; + } - if (trace->tep) + if (trace->tep) { tep_free(trace->tep); + trace->tep = NULL; + } } /* -- 2.35.1