Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3130118ybi; Thu, 18 Jul 2019 21:37:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHV1XxAvAv/quyfKYYzd3lSAlSFA6FjTm9YxkXMfdJ83Mz2vSLF8qnDcc1jZbzrpfDXcck X-Received: by 2002:a63:9249:: with SMTP id s9mr50120560pgn.356.1563511022086; Thu, 18 Jul 2019 21:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511022; cv=none; d=google.com; s=arc-20160816; b=aQkVtEH3LPYm87GaI2LO9FKIc5PJnXNsRI0AX6G/KdKw0cz/l7Ql/y0XZlaZqfQrpw b4lRTwsctI6rA0XItw3mj1hjNJPiUVjCwvVoT8YVU+TXWgENuLJvRvQqf7XyaV9UUQ+p /L/hEGs03uaKjhVuttybxfY54Y9r1cuc/Mz6Vf/bMPDapaS5whU26QdWYUgc7OofmtcC xR55SbJLXRunV03gZ8f8yYXSiEdjp/7GbIev3KiiRmRtIiwRFVdncsFbDU+viKQVdNA9 E+HbtQ16YQZFA02gXfQqSJRmDoODL/85cr6cUE1ALcVaiZV8KpHJ1rAeNJbmVj1l0PmA 2RKw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AmKR289s2N2ly6vWBq3LPQlEguzuEPLNlSslxqVKO5I=; b=r2wxTi7zLW2UY8fQhgbfqu+FkDKItWpebfBvoFCZruKcDo2XXJFmyArXSEktXwkeSA /sMQKH8z0e8hI5OYNzjoYplfPm9zHNlYixGCCnsn8o02aIQGo5OOTgfvD4ud5mK/mgNX mfCLnac/LiUoe51QI6P9WxDjdo8jVt45IC9DgR6cXGJqgIUxRzQLbP9fvwQsiNIQcmKO MlHav370+XRoXZxojaaMNFmHX/h7Cyb34i1+unwuelcIAa6zjoRurUWBvbOXLvTyDqgy mkbLrRWPJCq1tHYBEArTsEmydiMK3zvUJ2Wk9hlHXLVg+e/ZgZg+O3jt0cRBaB9jW8u7 wsEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ktqjFaQa; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a18si1807926pgg.28.2019.07.18.21.36.46; Thu, 18 Jul 2019 21:37:02 -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=ktqjFaQa; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730742AbfGSEfj (ORCPT + 99 others); Fri, 19 Jul 2019 00:35:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:33034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728581AbfGSEBU (ORCPT ); Fri, 19 Jul 2019 00:01:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7FC2F218BA; Fri, 19 Jul 2019 04:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508879; bh=KvJVT3OxbW7ZfxoOeAj1LriJxnXXyQaXFDAw6GDtAw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ktqjFaQaWmZaDRYTXFVLDw7CKX4EgxcJacJjbJMGO04YuGqzYig5DgYgX0nv///Kl zTHEPC/ioVgf3e4vCNIXuKt5vTToTfLUDEEng4vEHhDFAuHv5dxRcNBeR12Pk9rxO9 Z8HIyVh9ci6y0pEbdi/+CrrZFwHM/oTOV7tJTbSc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: 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 AUTOSEL 5.2 133/171] perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool Date: Thu, 18 Jul 2019 23:56:04 -0400 Message-Id: <20190719035643.14300-133-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan [ 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