Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1969565ybi; Sat, 13 Jul 2019 04:11:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzaGxoYSSYBLTpGqblnsUQ8mhhrNlJA+3YIlZMvYSMbQziS5LXU7x/UNed0hOnu+YABsBc X-Received: by 2002:a17:902:296a:: with SMTP id g97mr16881918plb.115.1563016295063; Sat, 13 Jul 2019 04:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563016295; cv=none; d=google.com; s=arc-20160816; b=foOtNeVqPsepf2NDEe5bmHXIC2CzsJxNdUVbVCZONxEHk3BgDnLb5iS9WyS9lddFlq iLMYkt8x+zB0JjvR0wchoWVHGDnhfkXeZ53MCCnRsF1ynHDa8DaGhWb4P4rSJEyf3ohg vodDfZyQXTNO5wDpPkis0ekih0fqCmJijMxtuOyO5QY2MeBXUlDt1W0xnmbzO2vM9dRI NO3KhGgHbk6vIzggsHDGGuixZATuMwQxR6bVHoI2Bmm0/xfCR0wdly4AP55AaU1rXBdZ OWpRKcC0qbTWkGNiXqL/eT+bxpyHMyTC4NQoQhOnmvk5J4axK8BI0L+BK6elCLOzww1W mp6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=z78sEZTdWtdDJhzAlgXWC5a3IveziytmFKX+TQMy1Sw=; b=fS7mGNyqAGudDw4XSAgXJkWY7igIdgD/N07d+gS4+l3RHbN8ZZsGRcEleap5u0tGIb YacQRlr4263dA+v6ziBndoRxs+uNLEnTQGMzloRTYSj7vDECivkOEmk5tTDHWbREtaZ+ a41LzWiYX6m1msVeO269UzePvmYKvJem94JBjM3k2U54hU+60zd3qbbQz1J4ZyGIENg7 Wuu89/JgCsoDyc2rvYtUNAyF8D3fl/+YzQ+4ohAKHy8J0FGKWHfsoeOslQE5o4WL2MgR 8T+Eh9ELnwIGkBNFuXbbyk60UOM8bTs61Jwe7VCwK7iAfGFQHyipWK+W0fB3EBxkonSJ ysGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=uC5zEyNe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u20si9923093plq.421.2019.07.13.04.11.19; Sat, 13 Jul 2019 04:11: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=@zytor.com header.s=2019061801 header.b=uC5zEyNe; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbfGMLK5 (ORCPT + 99 others); Sat, 13 Jul 2019 07:10:57 -0400 Received: from terminus.zytor.com ([198.137.202.136]:60799 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbfGMLK5 (ORCPT ); Sat, 13 Jul 2019 07:10:57 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6DB8jK73841284 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 13 Jul 2019 04:08:46 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6DB8jK73841284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1563016126; bh=z78sEZTdWtdDJhzAlgXWC5a3IveziytmFKX+TQMy1Sw=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=uC5zEyNeJP5FzV0WEyxL03z1Gf6fAGSXx9Xe09jwNa6LhCPypva+J7UGlBo1tpqsq GvCQxdHkmd4rQO7DvquoZRliZ6IDTAYG6QGJyCHAhuvTqZjK6PPvprlEMspQcfclmK /hTURvLq2DSAfAaS/MGlDEQUg1/TYmZAi5F9qVnzBwNVclGhvyWwJpDDufE3Pts/ig AMXAJvlopcc5YKnjytvsI2hjIc4ED6SCe99ARaIu8PyoD793TqzScMwUyUb0EMyZir JtxfrUu8UOvTseL7RwUD3KOr5zm/+tKusmI0F2rgN4Ykv/T6PcgAY9NATUbTsq7wvS 86b+Zf9H3nfew== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6DB8iYx3841280; Sat, 13 Jul 2019 04:08:44 -0700 Date: Sat, 13 Jul 2019 04:08:44 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Leo Yan Message-ID: Cc: tglx@linutronix.de, mingo@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, leo.yan@linaro.org, ak@linux.intel.com, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, acme@redhat.com, suzuki.poulose@arm.com, hpa@zytor.com, adrian.hunter@intel.com Reply-To: mingo@kernel.org, tglx@linutronix.de, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, ak@linux.intel.com, acme@redhat.com, mathieu.poirier@linaro.org, adrian.hunter@intel.com, hpa@zytor.com, suzuki.poulose@arm.com In-Reply-To: <20190708143937.7722-3-leo.yan@linaro.org> References: <20190708143937.7722-3-leo.yan@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool Git-Commit-ID: 1d481458816d9424c8a05833ce0ebe72194a350e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1d481458816d9424c8a05833ce0ebe72194a350e Gitweb: https://git.kernel.org/tip/1d481458816d9424c8a05833ce0ebe72194a350e Author: Leo Yan AuthorDate: Mon, 8 Jul 2019 22:39:35 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 9 Jul 2019 10:13:28 -0300 perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool 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 --- 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 5a21bcdb8ef7..5560e95afdda 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; }