Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3524203pxb; Mon, 24 Jan 2022 11:22:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi3VaXp6KHeDZWeqd+17DGkbibmJyfiy1a7TKmX9vYMJ2OnkpsechZOGDqK5CcmWdoHIh4 X-Received: by 2002:a62:180d:0:b0:4bb:dafb:ff50 with SMTP id 13-20020a62180d000000b004bbdafbff50mr15256023pfy.45.1643052152362; Mon, 24 Jan 2022 11:22:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643052152; cv=none; d=google.com; s=arc-20160816; b=EadkebDlhciqbMbuJJMl9pFnkyOmOdz/abTDHbajZ375VZ2iKlFoUA6NNRwXP0ajZU B8QnhFmenk3L/ZoFr/1KMGH8UMQ0Ut4VYAZ99QCdr0LvlaWIqp3orHwo0XVrKLKC5g/S 0pCS0tXvN3MPUVCwQOEW850d2P/WNhL0ZxyTdxXxTJxTKMJYgSqzuI9B6J5xko1EpONd KbIgi3fEbDOcmW/fJ/MCkjESgzjrO8cezuVuTswTpgTJymxpaB12B2kRPJsw7IwE6OqK MEBbgg+cnF9sMZAIzwmBQkydNhOsw4Xv42ILE0IkARjAA2u3jl0+1n/pbWlyvgF5/eF2 0+ww== 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=E04dO3J7+evKgbdBXIU4LpUNxJOPbkLESNcDrK8+2Wk=; b=WSjYSY3BUBan3VQ8LDw8WGKXYQdUEUGwYT3AuMyoUfviCQaTgr5wpIbXQd4njNQMhy hFBeXk68URmgCyRb9xBvS+wAVFuXX0zGTDw8RB8Bon7XMO2kZyXJQA+edWDxU84+d25R y19B6Kqr1PlTZt2mp2Yea+puM6XiuEZw5Y+aIlN/dYVn88Pd/s2bGsQpDpzm+9M/4L93 aNfJ+L1w2mZre+Sf6IRxLkHUeEYAH6Lurzp54YgAfaZP77r4za+oFDGnAfvcGk8BURDO u7GnmLQRfTYOOK+f3ZvyaxgGKsyMjfWrt6DXzE7FhjzPOi3GC4XIt+oHeIn2TGwj9OZE 5F4A== ARC-Authentication-Results: i=1; mx.google.com; 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 n6si16328709plh.1.2022.01.24.11.22.18; Mon, 24 Jan 2022 11:22:32 -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; 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 S238116AbiAXOYv convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 Jan 2022 09:24:51 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:38885 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237825AbiAXOYf (ORCPT ); Mon, 24 Jan 2022 09:24:35 -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-303-VUguLINpPQqnkC_q7BEGoA-1; Mon, 24 Jan 2022 09:24:33 -0500 X-MC-Unique: VUguLINpPQqnkC_q7BEGoA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 960D51091DA2; Mon, 24 Jan 2022 14:24:32 +0000 (UTC) Received: from x1.com (unknown [10.22.32.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40843798B2; Mon, 24 Jan 2022 14:24:31 +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 5/8] rtla/timerlat_top: Fix segmentation fault when failing to enable -t Date: Mon, 24 Jan 2022 15:24:08 +0100 Message-Id: <2fea7678dda97e09ef80fd5775abf51fc105a857.1643033113.git.bristot@kernel.org> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bristot@kernel.org 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 timerlat top is 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 timerlat top -t failed to enable the tracer timerlat 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. Rearrange the order in which trace instances are destroyed to avoid this problem. Fixes: a828cd18bc4a ("rtla: Add timerlat tool and timelart top 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/timerlat_top.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c index 1ebd5291539c..323fd1f88313 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -584,7 +584,7 @@ int timerlat_top_main(int argc, char *argv[]) trace); if (retval < 0) { err_msg("Error iterating on events\n"); - goto out_top; + goto out_trace; } if (!params->quiet) @@ -606,12 +606,12 @@ int timerlat_top_main(int argc, char *argv[]) save_trace_to_file(record->trace.inst, params->trace_output); } } - +out_trace: + if (params->trace_output) + osnoise_destroy_tool(record); out_top: timerlat_free_top(top->data); osnoise_destroy_tool(top); - if (params->trace_output) - osnoise_destroy_tool(record); free(params); out_exit: exit(return_value); -- 2.34.1