Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2984991rwb; Mon, 15 Aug 2022 15:29:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR7fM0JmbjeKFApeH10v/XQV6p53R+G98Xu2wtU5XlUgZxpzHaETnNp8gS5t1YAElvO5ndpW X-Received: by 2002:a17:902:c10d:b0:16f:d85:6139 with SMTP id 13-20020a170902c10d00b0016f0d856139mr18996743pli.34.1660602539929; Mon, 15 Aug 2022 15:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660602539; cv=none; d=google.com; s=arc-20160816; b=Eme+SUBXLZRqQqRSIxpa2xb7zvB9rhXjOJCXvpLRPA6fkyiUwbDd9RaJsgZq4pLpYG cW/q+6gG2R0lECjaUtdtUOzrE1gCH8mwULyp1BM1lfucDOvfywP+VbUJrHpKGms1UENJ DkGQDe8xuy8yir+Yml4SVKIuEBsKjlWdW4ra/pSIrF33I8khofpYOAaBif8/0v7WRZCE U4BtqUGAzQF16H8d8+rgrXy9SVtMTL/aAU5plFdx5V6qhmqzG3mvT5PUb856I++hOgXs 1nH7z9A+t1pBfjkx2qBah0MXS4qs1uzdL+SW/bIFzoQd3GE3t0uuIB/PmXPEHF25qwNO kidQ== 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=Ij2UQQpf1sfSfapYF9NMxNksbs931fQSpq7lXmJMgD2Ixk5lerxv5V+P0rIrbtY2AI vrOI9InX4t1ZVsW8Ga1z47s2K4nRkt5PMQnaOfn5V0aeKm72WgyHPosxQoit/HZ7EaP8 BLd0n/WEDWdocu+k8Qdj408UTdBW+FiQb5mHfzBg4VXoIR2xrfRtIC8tca/QzJeYDuM+ QPuv92W4S3/WBKaz6Di9oVHUACN3FnGJW5SQKAXA33C7iGrGlbyrq+/L8AyvDhXJkuVS v5k8oP7InofA8sgajfMclHdJzO82o6fKpRrI313U3r6wexf1oMScwKD6lI73i50hW27u NpTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kMjr+6xn; 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 e6-20020a170902ef4600b0016f8e803373si12305794plx.394.2022.08.15.15.28.47; Mon, 15 Aug 2022 15:28:59 -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=kMjr+6xn; 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 S1350157AbiHOW0Y (ORCPT + 99 others); Mon, 15 Aug 2022 18:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350874AbiHOWSp (ORCPT ); Mon, 15 Aug 2022 18:18:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA28A65827; Mon, 15 Aug 2022 12:42:56 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3B368B80EA9; Mon, 15 Aug 2022 19:42:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9890CC433C1; Mon, 15 Aug 2022 19:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592574; bh=WMHuwJF65OUTic2MXusj7pI//kwnDmHogdmjBJcNqpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kMjr+6xnfIH6EkyoCuF+aMeJRdQF/hMNwZblbzih6+IYNpy1b3xf9zDsmX5LnmkaD CkZpExMfwmooH4i0FWqJ0Zt2i5/l2++IhqZ37g0QDRztJ+ZkRY6SBhO5TKw54LlhiZ yMAzJJ7GDcANosB+sDQLkYB6v0vp5vcfa1vTJAKc= 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.18 0810/1095] rtla: Fix double free Date: Mon, 15 Aug 2022 20:03:29 +0200 Message-Id: <20220815180502.775652783@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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