From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752186AbbCJDj0 (ORCPT ); Mon, 9 Mar 2015 23:39:26 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:14603 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750976AbbCJDjZ (ORCPT ); Mon, 9 Mar 2015 23:39:25 -0400 Message-ID: <54FE6753.8090703@huawei.com> Date: Tue, 10 Mar 2015 11:38:59 +0800 From: He Kuang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: , , , , , "namhyung@kernel.org >> Namhyung Kim" CC: , Subject: Re: [PATCH] perf hists browser: Fix segfault when all entries be filtered References: <1425442416-29035-1-git-send-email-hekuang@huawei.com> In-Reply-To: <1425442416-29035-1-git-send-email-hekuang@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.110.54.65] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.54FE6761.003C,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f79083d0d87cc420ede8ee8cf04bbb9f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping.. On 2015/3/4 12:13, He Kuang wrote: > When all perf report entries be filtered, the result of > hists__filter_entries() can be NULL, check the result before processing. > > Miss this checking will cause segmentation fault like this: > > $ perf report > > (filter all entries and left nothing, then zoom in/out) > perf: Segmentation fault > -------- backtrace -------- > ../bin/perf[0x4d1858] > ../lib64/libc.so.6(+0x3545f)[0x7fe72fc1145f] > ../bin/perf[0x4cd9f5] > ../bin/perf[0x4ce176] > ../bin/perf[0x4d0506] > ../bin/perf[0x41a94f] > ../bin/perf[0x408cf2] > ../bin/perf[0x408455] > ../lib64/libc.so.6(__libc_start_main+0xf4)[0x7fe72fbfdbd4] > ../bin/perf[0x408584] > > Signed-off-by: He Kuang > --- > tools/perf/ui/browsers/hists.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c > index 788506e..1106bb8 100644 > --- a/tools/perf/ui/browsers/hists.c > +++ b/tools/perf/ui/browsers/hists.c > @@ -992,6 +992,9 @@ static void ui_browser__hists_seek(struct ui_browser *browser, > * and stop when we printed enough lines to fill the screen. > */ > do_offset: > + if (!nd) > + return; > + > if (offset > 0) { > do { > h = rb_entry(nd, struct hist_entry, rb_node);