Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5496303pxb; Mon, 7 Feb 2022 03:26:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQOPmf5l6VDank8Kxyh1AJDHIQMP12A6IZYordohO0/zoPOSZSp+q6MW/LvULM3D2WUv4Q X-Received: by 2002:a05:6402:27c9:: with SMTP id c9mr13523506ede.178.1644233204558; Mon, 07 Feb 2022 03:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644233204; cv=none; d=google.com; s=arc-20160816; b=XyJl6SmP9I2nJCn9MASeidWA8jQpz05aR+jbgmyBbBuqfNh708yA7MxaXCiB9JhRvA LAMlELDykJmur76mMtuALmIdI2/vOBZl1kaQYscTbqCc8vWLa+Oc0/PnNRLHPTY1SZJg eOiqWmujE7ujCelAwbaHSF3vM9yMpxIzz+/96HHfVM0lbwZbl+m7yOQh8xIc2ZXOZ3yL 8FGwvGDeJfUEzFae9sP7k7Qd9HHqNwc7dHq3ZH3J7JbE6kwp8M4dY7Sf2EaV8eNRSUVQ TWGyR3oicmT6KwDo4AEIssvudJm0970NUMmlYYvXQTnw/Dsv0TFAvvHef7Iw4PhdmMBh HukA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Fk9qKIVdAeNEWY9W0uRKbUK5JKhTPM9Am6Ypg4rsEak=; b=cq5HeZPEjWFuIDzRnkgbiC4hT0ZSdGqJnxXgWue2u4kv3E5rcil3Y3d7kP1LAu1aKW asoyIp5mwAUo5QuktLffwo5UfICIvutzdSVIYE8tm6i85b/9TNGdiHRSnURmFVknmECz 0mb2X3LmpyO5a8/0ZG8dHhyEJ1emJqd7YHwnWFsbqMyHTqirFv5We6JBrdjfErw9YpFT BcOVrYewCcXOazmVFI1hEL2jUiz8Wp80FJUFl2YRbtCX7LyEJAv026La5L9NJIbQUjNs h3RLEN4MY8weI4sp1P/t2JXmE5b7ffZLjMkIkPSeoVur96L2CDtU4O9BpVdKNFd903np atRg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m19si8098418edd.539.2022.02.07.03.26.20; Mon, 07 Feb 2022 03:26:44 -0800 (PST) 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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356399AbiBDQYf convert rfc822-to-8bit (ORCPT + 99 others); Fri, 4 Feb 2022 11:24:35 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:29567 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376564AbiBDQYX (ORCPT ); Fri, 4 Feb 2022 11:24:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-rV3NRtUVMxaCyBGTewz_8A-1; Fri, 04 Feb 2022 11:24:19 -0500 X-MC-Unique: rV3NRtUVMxaCyBGTewz_8A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF53C1853026; Fri, 4 Feb 2022 16:24:18 +0000 (UTC) Received: from x1.com (unknown [10.22.33.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7C8B7E91E; Fri, 4 Feb 2022 16:24:17 +0000 (UTC) From: Daniel Bristot de Oliveira To: Steven Rostedt Cc: Daniel Bristot de Oliveira , linux-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org Subject: [PATCH 4/4] rtla/osnoise: Fix segmentation fault when failing to enable -t Date: Fri, 4 Feb 2022 17:24:05 +0100 Message-Id: <264ff7941b7551ec0b6e5862e40cf3dd593d0ff0.1643990447.git.bristot@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rtla osnoise and timerlat are causing a segmentation fault when running with the --trace option on a kernel that does not support multiple instances. For example: [root@f34 rtla]# rtla osnoise top -t failed to enable the tracer osnoise Could not enable osnoiser tracer for tracing Failed to enable the trace instance Segmentation fault (core dumped) This error happens because the exit code of the tools is trying to destroy the trace instance that failed to be created. Make osnoise_destroy_tool() aware of possible NULL osnoise_tool *, and do not attempt to destroy it. Suggested-by: Steven Rostedt Fixes: 1eceb2fc2ca5 ("rtla/osnoise: Add osnoise top mode") Fixes: 829a6c0b5698 ("rtla/osnoise: Add the hist mode") Fixes: a828cd18bc4a ("rtla: Add timerlat tool and timelart top mode") Fixes: 1eeb6328e8b3 ("rtla/timerlat: Add timerlat hist mode") Cc: Daniel Bristot de Oliveira Cc: Steven Rostedt Cc: linux-kernel@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/osnoise.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/tracing/rtla/src/osnoise.c b/tools/tracing/rtla/src/osnoise.c index 7b73d1eccd0e..5648f9252e58 100644 --- a/tools/tracing/rtla/src/osnoise.c +++ b/tools/tracing/rtla/src/osnoise.c @@ -750,6 +750,9 @@ void osnoise_put_context(struct osnoise_context *context) */ void osnoise_destroy_tool(struct osnoise_tool *top) { + if (!top) + return; + trace_instance_destroy(&top->trace); if (top->context) -- 2.34.1