Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4131501ybi; Mon, 29 Jul 2019 19:57:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXHBIJB2r/o2IaWlTDMTtX1m1WqrYjuCUv1SaZrPEDneqpDkIJwQ9FaDE6SFa4GuztCk1M X-Received: by 2002:a63:cb4b:: with SMTP id m11mr33077050pgi.49.1564455455407; Mon, 29 Jul 2019 19:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564455455; cv=none; d=google.com; s=arc-20160816; b=pNQ6ReBBoJEJT1Dh1qESn9e5Ut2HLfP5s9XI78ahb5Sa4uWpjk8gOv5m2jwmOTIHQ/ G6LfmhGfo/kIDHP1b41GRU8C1UooKQXUeds7j1vBb5pEKGp563eZa2vPqL1lDTS+1uO1 i5mjBZ2sn0JKDsrSQfxkuw75oKT4eiFwUVt7/RoJlhG3pU2x7g3ZsNjNUfMOWtdtBBm1 SupSNNK1uKxtKZHPuRQIMkNvctuSy0XbqptAf+ZXHrBB7jLYkSxZU/3qTsu8mVrqmazi MbWsLgigXv5yBuR/dVVDdXTvHYi/JCZ+eOPIsqvM26efmNKsmG4o/LrIZy2U4BZnooty sx9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2jqJLYLFYc89K2B/SNKvCRKS4DItyEbyQlRtYqOYvB8=; b=sq/G/TwHohCDuqVeI6tVEAwBCsUlLbW2VJq4QvnTMeWPGV7mrNix3hBMVIXqk54fs0 nr/vHsCQlRGuRH1xLclUiYQmOQZdBC3pGAq3kNHaoQlIEYqQffhFylr7JOEiYl/7qJLs FNK8kadyyLkUObJtZ3sjxXejkDq+RlET/TUQVg1SsPj8+3NyEGucOuKhNJoB/Ghm747h MgAUFBv3J0NvKl6T51nu9RxpIDqmI22eUCoIAhV2LIYvk1G/nmBQ76Jnl5yL6VEthYwp KTJ0Coq4RzxSG+mQg+6kR1WZxOkhp/ustSaKNI7L/qFuTIrW1tuu3f2INHdwbQXrW27g k8aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JVs9C+dT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si29397769pgd.247.2019.07.29.19.57.12; Mon, 29 Jul 2019 19:57:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JVs9C+dT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390805AbfG2Tvh (ORCPT + 99 others); Mon, 29 Jul 2019 15:51:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:43028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390790AbfG2Tve (ORCPT ); Mon, 29 Jul 2019 15:51:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C24242054F; Mon, 29 Jul 2019 19:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429893; bh=+msWdbPn29tMENfyQxYBG+5FjIxE3qx68j5Xh9RrvLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JVs9C+dTFnWRpbJHT43PWIGQBwBdhaayXLVJtyHce16K6Stz91womZqKupuHj1WLf 62Wz62oLGiTuktPzCgIq5cJGTmN9sQhQbSXqCyazbK+QqQgufTqvMbw6BVavUdcNov QqfUE6qODUGSQY8wX97KvJl9ek8McLgDqThdI3fo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Adrian Hunter , Alexander Shishkin , Andi Kleen , Jiri Olsa , Mathieu Poirier , Namhyung Kim , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.2 130/215] perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool Date: Mon, 29 Jul 2019 21:22:06 +0200 Message-Id: <20190729190801.948791723@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1d481458816d9424c8a05833ce0ebe72194a350e ] Based on the following report from Smatch, fix the potential NULL pointer dereference check. tools/perf/util/intel-bts.c:898 intel_bts_process_auxtrace_info() error: we previously assumed 'session->itrace_synth_opts' could be null (see line 894) tools/perf/util/intel-bts.c:899 intel_bts_process_auxtrace_info() warn: variable dereferenced before check 'session->itrace_synth_opts' (see line 898) tools/perf/util/intel-bts.c 894 if (session->itrace_synth_opts && session->itrace_synth_opts->set) { 895 bts->synth_opts = *session->itrace_synth_opts; 896 } else { 897 itrace_synth_opts__set_default(&bts->synth_opts, 898 session->itrace_synth_opts->default_no_sample); ^^^^^^^^^^^^^^^^^^^^^^^^^^ 899 if (session->itrace_synth_opts) ^^^^^^^^^^^^^^^^^^^^^^^^^^ 900 bts->synth_opts.thread_stack = 901 session->itrace_synth_opts->thread_stack; 902 } 'session->itrace_synth_opts' is impossible to be a NULL pointer in intel_bts_process_auxtrace_info(), thus this patch removes the NULL test for 'session->itrace_synth_opts'. Signed-off-by: Leo Yan Acked-by: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190708143937.7722-3-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/intel-bts.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index e32dbffebb2f..625ad3639a7e 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -891,13 +891,12 @@ int intel_bts_process_auxtrace_info(union perf_event *event, if (dump_trace) return 0; - if (session->itrace_synth_opts && session->itrace_synth_opts->set) { + if (session->itrace_synth_opts->set) { bts->synth_opts = *session->itrace_synth_opts; } else { itrace_synth_opts__set_default(&bts->synth_opts, session->itrace_synth_opts->default_no_sample); - if (session->itrace_synth_opts) - bts->synth_opts.thread_stack = + bts->synth_opts.thread_stack = session->itrace_synth_opts->thread_stack; } -- 2.20.1