Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5569746rwe; Tue, 18 Apr 2023 08:30:14 -0700 (PDT) X-Google-Smtp-Source: AKy350aZGqlVb/9o3tT/nQ6R3JqrEGJkR8g2yC6Po54MOw5gHL6tZju27HJa9++/miPificEFXHh X-Received: by 2002:a17:90a:8f05:b0:23d:3698:8ed3 with SMTP id g5-20020a17090a8f0500b0023d36988ed3mr114002pjo.22.1681831814448; Tue, 18 Apr 2023 08:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681831814; cv=none; d=google.com; s=arc-20160816; b=RAUU/ewr6OtXM7qzuGm3XNFTtsqup+YcI9USYmJowQDRQ6YWf5Ysc+u1c3gqQmiWE8 tetxX3xwRNyFoRtUNnICQRMCiPEOitV1UJTZNcCfPhi1zYPWyCGNJJlAIyhQwyWN+TgO T54g1/v2rlmiBazR48v6CoaYOd7Hm+7g/6a1BjJByJxn6mGYP3e84sslWiXiJREcV2DT hfSR0Lv52Qg1eGc/bFVAB1fE4Yy8B5hyQsfuhqQYdFs2hemAIbeGez8WhftNIvyXPJEz 4mCj0F/dycGPYF9WJD41JK7QEP8fkg/bmw8+tiQC0ofCvIw29BaF3IKyyFS06o0zcukK Tvyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YCTelmaiL+W9uSQ/wf6s9ElNzZfZeY9mnGRdeDNDvts=; b=mdpqSh6+jfUMQE1DuUQJ2TChXbcR+JotR/dN49wo/64kmQUsfcht95VRxXr2m3QYkP Lnl8g30yTuu4sOFFKpd4wHEw9fcnn3o/eBw9BuD3N4NMq1dc0E2N5mg6tKg2DLkcfkFb JZSLu8xyGrOYEm3aNQR5NIs51SRYl44qAtGC9z+ewv4nIXlHkMWosSZLvp+SrGHdLyTW HZRiyAWH1/DYLi6ORXxafvI8MIo8gxCuP37lzOqsyzZM53GmC/C8XyTvSN6MUaD47ofP kAoBZo5cQm6SL/ftFBH8iV5nqnhzAJj2Ss1lwTPC1QrjcD81H11hyYj/wp+Qg+x4sv+n NMMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Vobw8tft; 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 c16-20020a17090a8d1000b00247498bcea7si10215817pjo.107.2023.04.18.08.30.01; Tue, 18 Apr 2023 08:30:14 -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=@kernel.org header.s=k20201202 header.b=Vobw8tft; 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 S232218AbjDRP0h (ORCPT + 99 others); Tue, 18 Apr 2023 11:26:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232240AbjDRP0e (ORCPT ); Tue, 18 Apr 2023 11:26:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2611F13F83; Tue, 18 Apr 2023 08:26:09 -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 B610A635D0; Tue, 18 Apr 2023 15:26:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E09D4C433EF; Tue, 18 Apr 2023 15:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681831568; bh=3D8Pa3erTkp9cKyukAUmfiAfX+D6cPFyYo1IyB4VYsQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Vobw8tftxLbNaE+3MzVTaI1eiuNb5OeSX2m8iSPINoQGSVG7xhf+jL7v0ukpNT6Gp IPVVPjmSp8zkzg/Vk7JX5QTypT0xzoH4qGE96LuFRHQfmsVXATGmmyGDkwBghPpctk cMXlnpI2uGEytU6NxiBl1fy6vhZljsvksM9wXidScyHUJL3z7uEU2uvclAj1eTAXh2 iUJF+xcFgD4JuUp/URvZbSMmym6mbMSZfS3bFOGUMP6/YWZovVla+aWeb6pCBUrdOA ZFILn+CCFLGqLLi6qezml25EdGvsiufoJHqjh39fg9VwKhjnsq/OetEHBp4kRFzCM5 hGcvF4z1IF99Q== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id EFA67403B5; Tue, 18 Apr 2023 12:26:04 -0300 (-03) Date: Tue, 18 Apr 2023 12:26:04 -0300 From: Arnaldo Carvalho de Melo To: James Clark Cc: linux-perf-users@vger.kernel.org, Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf: cs-etm: Fix segfault in dso lookup Message-ID: References: <20230418141203.673465-1-james.clark@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230418141203.673465-1-james.clark@arm.com> X-Url: http://acmel.wordpress.com 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 Em Tue, Apr 18, 2023 at 03:12:03PM +0100, James Clark escreveu: > map__dso() is called before thread__find_map() which always results in a > null pointer dereference. Fix it by finding first, then checking if it > exists. > > Fixes: 63df0e4bc368 ("perf map: Add accessor for dso") Thanks, applied, checking if another such pattern slipped by in that cset. - Arnaldo > Signed-off-by: James Clark > --- > tools/perf/util/cs-etm.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 103865968700..8dd81ddd9e4e 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -885,9 +885,11 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, > thread = etmq->etm->unknown_thread; > } > > - dso = map__dso(al.map); > + if (!thread__find_map(thread, cpumode, address, &al)) > + return 0; > > - if (!thread__find_map(thread, cpumode, address, &al) || !dso) > + dso = map__dso(al.map); > + if (!dso) > return 0; > > if (dso->data.status == DSO_DATA_STATUS_ERROR && > -- > 2.34.1 > -- - Arnaldo