Message ID | ZN4R1AYfsD2J8lRs@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2222199vqi; Sat, 19 Aug 2023 15:41:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGryYI4JDbVBT4grrGBr8R/WE5P9fwH+fDnSRtlDlqROV3HC1bzbMuMyXaDUMfborgEeu64 X-Received: by 2002:a05:6a00:1502:b0:682:7d8a:f891 with SMTP id q2-20020a056a00150200b006827d8af891mr4348847pfu.20.1692484879491; Sat, 19 Aug 2023 15:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692484879; cv=none; d=google.com; s=arc-20160816; b=mJjRlpNU6o3r9k2owNFgGLR74Gy2iHG1/Ey7Anncb95k2pCKAnC3hWsgr2pbaVMo15 SZH+0TG6iAidZGDr/o6fgRFGAP3zk++ACmo5fmJxB8iaOyFDB7hsG6pq/a8730EKxymY qAzChLD8y9y4t0k/mn/nED5i7D/OxbPW7x+HQWSa10tkLGbRLJxq25PXSHMaKDzO0IgE 3B7YBBVFMA2Nwj11EIa17OWJskr4Fg1+aR4EH+jW42i7SylNDG7eYBLPEKkRA/RFY/A2 xRYE3k1vlr8bybL/Hpbezal6ca+zXwJI3hLrMj1eXoJDNL6lvl1SY48egzDUfw+gWgVJ EqUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=4uG2Yu8N3aeYyfeI8+oi+/82opxhmT3EK21HUykbKus=; fh=yLyu8BtwCK8XUghg0ziBEitjyjLxYb4az6n7ceuncnk=; b=jL73k9JVyRwRb2XD9aDGeQusj5GGfnXLB9o98f0y5VUP5SrlKBy7Lk+98kZ4EdMgcp g4eq5Hj0Tw2TMhUGBRqojdUtT7b8EIsC845jRUsPApy4eOKRROdqUEEk4hp0mEqr6M9w qwpEE6YSdXUClGLpEjNEbJBDgUDp+m0RIrDUNsp2bQP9qRVMEUtAcC0AwfpokCvagE4f zu9uEentUpzsCS/6JGjj+mxmX1PK53fqbhg2TrxC0BaQRK0OydcT65aYi3FqdTqdWNAG 0uYICWbrufoqbg+fjDqNhBpfRKI5IWnOoAlzYlnmDwCZzrS6Qze8DRcpHZz/s2NIaFF3 rZHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEjB04f5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p4-20020a056a000a0400b0068269b1ebcbsi4329498pfh.394.2023.08.19.15.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 15:41:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEjB04f5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78A1DB240; Sat, 19 Aug 2023 11:02:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350831AbjHQM0K (ORCPT <rfc822;somadevkernel@gmail.com> + 99 others); Thu, 17 Aug 2023 08:26:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350852AbjHQM0D (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Aug 2023 08:26:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FCEA2D4F for <linux-kernel@vger.kernel.org>; Thu, 17 Aug 2023 05:26:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A27DF63833 for <linux-kernel@vger.kernel.org>; Thu, 17 Aug 2023 12:25:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAD5BC433C7; Thu, 17 Aug 2023 12:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692275159; bh=PQ2/X/AtlvaWHfySk7Tb3snsBUdfjq4Kk2LfPPOqlPU=; h=Date:From:To:Cc:Subject:From; b=dEjB04f5myBBRMdiMFKK7cydK7sp8Z2kzGV5Q7BWt9ooj800rgaNr685DDQHk5nbS 3Xz0Gxtb/PIgnTGfaZ+tewMgdVYjayGqCLzU5JM1jl+hvK6UoMFP0jrygPPJUEooQ3 /ki7RI27T8ks18FzesBFbPL6XMEdSenYrMFRzBA+saEN0gMdO7qw10lqzc54aWm8sq ZHb23p+hZO5AVOZYzeKO4uBdd4wStu0PuSXxhDIStFPihzEKXfYxxXlAgYhwciiSHN 9Y/LF+TU/AICCTK/G/Fc5Wo8u52+dvrHcVJo4jwfoAVX6ioOwCSh5DwwiaU/qhRemf D4GnRZD5TAURw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 73AD7404DF; Thu, 17 Aug 2023 09:25:56 -0300 (-03) Date: Thu, 17 Aug 2023 09:25:56 -0300 From: Arnaldo Carvalho de Melo <acme@kernel.org> To: Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>, K Prateek Nayak <kprateek.nayak@amd.com>, Kan Liang <kan.liang@linux.intel.com>, Leo Yan <leo.yan@linaro.org>, Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>, Mark Rutland <mark.rutland@arm.com>, Masami Hiramatsu <mhiramat@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Paolo Bonzini <pbonzini@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Ravi Bangoria <ravi.bangoria@amd.com>, Ross Zwisler <zwisler@chromium.org>, Sean Christopherson <seanjc@google.com>, Steven Rostedt <rostedt@goodmis.org>, Tiezhu Yang <yangtiezhu@loongson.cn>, Yang Jihong <yangjihong1@huawei.com>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: [PATCH 1/1] perf lock: Don't pass an ERR_PTR() directly to perf_session__delete() Message-ID: <ZN4R1AYfsD2J8lRs@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774699025270994872 X-GMAIL-MSGID: 1774699025270994872 |
Series |
[1/1] perf lock: Don't pass an ERR_PTR() directly to perf_session__delete()
|
|
Commit Message
Arnaldo Carvalho de Melo
Aug. 17, 2023, 12:25 p.m. UTC
While debugging a segfault on 'perf lock contention' without an
available perf.data file I noticed that it was basically calling:
perf_session__delete(ERR_PTR(-1))
Resulting in:
(gdb) run lock contention
Starting program: /root/bin/perf lock contention
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
failed to open perf.data: No such file or directory (try 'perf record' first)
Initializing perf session failed
Program received signal SIGSEGV, Segmentation fault.
0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
2858 if (!session->auxtrace)
(gdb) p session
$1 = (struct perf_session *) 0xffffffffffffffff
(gdb) bt
#0 0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
#1 0x000000000057bb4d in perf_session__delete (session=0xffffffffffffffff) at util/session.c:300
#2 0x000000000047c421 in __cmd_contention (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2161
#3 0x000000000047dc95 in cmd_lock (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2604
#4 0x0000000000501466 in run_builtin (p=0xe597a8 <commands+552>, argc=2, argv=0x7fffffffe200) at perf.c:322
#5 0x00000000005016d5 in handle_internal_command (argc=2, argv=0x7fffffffe200) at perf.c:375
#6 0x0000000000501824 in run_argv (argcp=0x7fffffffe02c, argv=0x7fffffffe020) at perf.c:419
#7 0x0000000000501b11 in main (argc=2, argv=0x7fffffffe200) at perf.c:535
(gdb)
So just set it to NULL after using PTR_ERR(session) to decode the error
as perf_session__delete(NULL) is supported.
Fixes: eef4fee5e52071d5 ("perf lock: Dynamically allocate lockhash_table")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Ross Zwisler <zwisler@chromium.org>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/lkml/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-lock.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index c15386cb10331829..0cf1c5a2e0323341 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -2052,6 +2052,7 @@ static int __cmd_contention(int argc, const char **argv) if (IS_ERR(session)) { pr_err("Initializing perf session failed\n"); err = PTR_ERR(session); + session = NULL; goto out_delete; }