Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2226760ybt; Fri, 3 Jul 2020 04:10:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCvVoFQv8CkgFb3AjnjxoXnowp8/ICN61em6PQM4Hhmf4UCG0WtbApUcjK7Z5Tbb82BkvB X-Received: by 2002:a50:ee01:: with SMTP id g1mr32344725eds.264.1593774644899; Fri, 03 Jul 2020 04:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593774644; cv=none; d=google.com; s=arc-20160816; b=bIbebbi2b1MRdMzkbn82g5x0jqVvIWRBXb9BDfd/bDztvmvN47i8u0HBN8ZAT6NeSH EmmBLBm41wofld6TArFJJ+SlOTSLN0dWxM2eHZvOsd0E8x6tBS/HbXRUau6h4GpSf0SH VNdvxoNvgnlPLarlhGbn8cn+ql8AtDPtdW/gpYfqa/7vDy8fWeU17XKXQyDoZ4jAF6xS PU9HAJFttwrv1YnLPSUwSAk98vSmQZ/dcU8x6Tz5Rgr3KBu5l+WjCR5aYgc6K5yOrQ2H 1GFZRT7G8DbFBoAXc1b3iR3EH1PHgLB1rfibqcOPDsvYZXorZ0b6h63Jxs7L36Y8e/U6 ukiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=wvVrEZd+9e1iWBtgYYnLv0ba/uEMSttTCVZCxWK/m/U=; b=wVMc5T0pWhgsAwU+ckOQ/Bl3SUmMPSOFWnWz+b0YmiPTi5kDeONI9hdKBY/0ZeYtK5 K0HCxkRhfwTcIaf9LtIKte1sgFmQ8JQzKYMewHXk8dU0jzu0Wa0QxVMrtjUWMMjWp6HF 2wn3wtv76OrphAXlJAVSmdiKr7MQFTohsmH2XU+C+9WiSDNUp38UkkB9CY5rGei7SWk2 lgpk+8VIyI2p87xbJNTdIGOT4oPZk759igbtrfgY1PUtDu4XwaNq+1JIcrgAz9gX91hu v5TaZ5DTAs8glX9dWkwYDKf3lmU6Ms6fxKiPMUK79gyzdDARPVolBvDaeMrpu6yCDgUb 7G0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PiXaajlD; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si9255559edf.278.2020.07.03.04.10.21; Fri, 03 Jul 2020 04:10:44 -0700 (PDT) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PiXaajlD; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgGCLKQ (ORCPT + 99 others); Fri, 3 Jul 2020 07:10:16 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28111 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725984AbgGCLKQ (ORCPT ); Fri, 3 Jul 2020 07:10:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593774614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wvVrEZd+9e1iWBtgYYnLv0ba/uEMSttTCVZCxWK/m/U=; b=PiXaajlDpac1SQ1Qv+rUHeEOQXjowjoSG4K901+dfvlE/T6OopTQLF+7HMhCdp81Q5YovE RpJXWCXLwJTr9olVMdr7ciOF8x1vL3DhEQAp1n3c6FmznW0huXDbGMQBBzWRvp6jUusBkq Lv1oDbeMSwnG4YRnxQk711kzUQ7LFcM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-N_pq_x-bOEGzbdzhR0gwMg-1; Fri, 03 Jul 2020 07:10:10 -0400 X-MC-Unique: N_pq_x-bOEGzbdzhR0gwMg-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 D212E107ACCD; Fri, 3 Jul 2020 11:10:08 +0000 (UTC) Received: from krava (unknown [10.40.194.24]) by smtp.corp.redhat.com (Postfix) with SMTP id D26D35D9CA; Fri, 3 Jul 2020 11:10:06 +0000 (UTC) Date: Fri, 3 Jul 2020 13:10:05 +0200 From: Jiri Olsa To: Wei Li Cc: Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , linux-kernel@vger.kernel.org, Jin Yao , Andi Kleen , guohanjun@huawei.com Subject: Re: [PATCH] perf report TUI: Fix segmentation fault in perf_evsel__hists_browse() Message-ID: <20200703111005.GB3282312@krava> References: <20200612094322.39565-1-liwei391@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200612094322.39565-1-liwei391@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 12, 2020 at 05:43:22PM +0800, Wei Li wrote: > The segmentation fault can be reproduced as following steps: > 1) Executing perf report in tui. > 2) Typing '/xxxxx' to filter the symbol to get nothing matched. > 3) Pressing enter with no entry selected. > Then it will report a segmentation fault. > > It is caused by the lack of check of browser->he_selection when > accessing it's member res_samples in perf_evsel__hists_browse(). > > These processes are meaningful for specified samples, so we can > skip these when nothing is selected. > > Fixes: 4968ac8fb7c3 ("perf report: Implement browsing of individual samples") > Signed-off-by: Wei Li Acked-by: Jiri Olsa thanks, jirka > --- > tools/perf/ui/browsers/hists.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c > index 487e54ef56a9..2101b6b770d8 100644 > --- a/tools/perf/ui/browsers/hists.c > +++ b/tools/perf/ui/browsers/hists.c > @@ -2288,6 +2288,11 @@ static struct thread *hist_browser__selected_thread(struct hist_browser *browser > return browser->he_selection->thread; > } > > +static struct res_sample *hist_browser__selected_res_sample(struct hist_browser *browser) > +{ > + return browser->he_selection ? browser->he_selection->res_samples : NULL; > +} > + > /* Check whether the browser is for 'top' or 'report' */ > static inline bool is_report_browser(void *timer) > { > @@ -3357,16 +3362,16 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events, > &options[nr_options], NULL, NULL, evsel); > nr_options += add_res_sample_opt(browser, &actions[nr_options], > &options[nr_options], > - hist_browser__selected_entry(browser)->res_samples, > - evsel, A_NORMAL); > + hist_browser__selected_res_sample(browser), > + evsel, A_NORMAL); > nr_options += add_res_sample_opt(browser, &actions[nr_options], > &options[nr_options], > - hist_browser__selected_entry(browser)->res_samples, > - evsel, A_ASM); > + hist_browser__selected_res_sample(browser), > + evsel, A_ASM); > nr_options += add_res_sample_opt(browser, &actions[nr_options], > &options[nr_options], > - hist_browser__selected_entry(browser)->res_samples, > - evsel, A_SOURCE); > + hist_browser__selected_res_sample(browser), > + evsel, A_SOURCE); > nr_options += add_switch_opt(browser, &actions[nr_options], > &options[nr_options]); > skip_scripting: > -- > 2.17.1 >