Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3217162ybi; Tue, 2 Jul 2019 04:08:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEt1w6y8fP57lVKbhmm+RVAqKV348rJoU+sH/Ouq6OIwsFxrgRXx7iReaNX2oYGFf+x61j X-Received: by 2002:a17:902:e40f:: with SMTP id ci15mr34731847plb.103.1562065706983; Tue, 02 Jul 2019 04:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562065706; cv=none; d=google.com; s=arc-20160816; b=1JMKzbd1W3XBjthQ3ex330ypTz8105TyWkKBrYyvqvqYJe5Af4E31Z5pDk4/ZoEl/I lOCEmDJFwIQ8Cs/dNSsIBky13G+wzMA9aKmODCaywEaDQs6mIY7wJkS3hy5xnyrjObrZ DoVkZD17fsebDp4EckEQmIoJYeOCwsB6TW11G03u+bc5Vvtg8/p8m5l2AK88kPcOAytQ XVQ5TNJqUtAjyU7HjavhbeHx8hu8FoT6xilljzw6Qx8U1kCmjlH51yg8R4p3lNaMwizm oJPJ9azYEtk9XbAMG+GezZRLfxxuzV+U4N2IRGrSFhE88Ch1Cu7jOZG53jOOsBOm1Csu AGyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KXWoVFS/MyBbNyHkmwkSl0BUCZPa7AcsZc3vvsx+YSU=; b=tCHKoMBFOLYo2AqD3oHbPz3avMSEUcib8txh0WmbP6RwqgXUAxS37UD19/sl7woHel k+I+QCM63fDM1Bnjqm6xTAL+n7kSez13pwP7qx36xSorsCOGhsSgCPObZDx1MyFxIGvp hG7DdMSem1MV/rF4pZK/24EPowm6R6tngm2jCUhaoHcRjedzBYDHPb82u7OuCaxzEcWx W3fu/n7R7ybCNYj7hqtrFuZl2WlpPM85CxrkWcQRCmEz9v6C//emda39oYKqav0bZteH ogcEzMwTZ9jGaXmuLOOOjypoeRbIpttJXLCtQak+fCkmeh2fr7WQJ3yzmlyRSbcqzTcv 1Uuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si9559348pgn.64.2019.07.02.04.08.09; Tue, 02 Jul 2019 04:08:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726457AbfGBLHs (ORCPT + 99 others); Tue, 2 Jul 2019 07:07:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57818 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbfGBLHs (ORCPT ); Tue, 2 Jul 2019 07:07:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E79EA120D7; Tue, 2 Jul 2019 11:07:38 +0000 (UTC) Received: from krava (unknown [10.43.17.81]) by smtp.corp.redhat.com (Postfix) with SMTP id 2AB116F921; Tue, 2 Jul 2019 11:07:29 +0000 (UTC) Date: Tue, 2 Jul 2019 13:07:28 +0200 From: Jiri Olsa To: Leo Yan Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Andi Kleen , "David S. Miller" , Davidlohr Bueso , Rasmus Villemoes , Jin Yao , Song Liu , Adrian Hunter , Alexios Zavras , Thomas Gleixner , Changbin Du , Eric Saint-Etienne , Konstantin Khlebnikov , Thomas Richter , Alexey Budankov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1 06/11] perf hists: Smatch: Fix potential NULL pointer dereference Message-ID: <20190702110728.GA15322@krava> References: <20190702103420.27540-1-leo.yan@linaro.org> <20190702103420.27540-7-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190702103420.27540-7-leo.yan@linaro.org> User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 02 Jul 2019 11:07:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 02, 2019 at 06:34:15PM +0800, Leo Yan wrote: > Based on the following report from Smatch, fix the potential > NULL pointer dereference check. > > tools/perf/ui/browsers/hists.c:641 > hist_browser__run() error: we previously assumed 'hbt' could be > null (see line 625) > > tools/perf/ui/browsers/hists.c:3088 > perf_evsel__hists_browse() error: we previously assumed > 'browser->he_selection' could be null (see line 2902) > > tools/perf/ui/browsers/hists.c:3272 > perf_evsel_menu__run() error: we previously assumed 'hbt' could be > null (see line 3260) > > This patch firstly validating the pointers before access them, so can > fix potential NULL pointer dereference. > > Signed-off-by: Leo Yan > --- > tools/perf/ui/browsers/hists.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c > index 3421ecbdd3f0..2ba33040ddd8 100644 > --- a/tools/perf/ui/browsers/hists.c > +++ b/tools/perf/ui/browsers/hists.c > @@ -638,7 +638,9 @@ int hist_browser__run(struct hist_browser *browser, const char *help, > switch (key) { > case K_TIMER: { not sure this can really happen, perhaps WARN_ON_ONCE(!hbt) would be good in here jirka > u64 nr_entries; > - hbt->timer(hbt->arg); > + > + if (hbt) > + hbt->timer(hbt->arg); > > if (hist_browser__has_filter(browser) || > symbol_conf.report_hierarchy) SNIP