From patchwork Tue Jul 9 18:31:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 168763 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8897612ilk; Tue, 9 Jul 2019 11:33:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMq16oqaa/uBvPmm7OppWwTak66YGkUhiceGJA/vfrIMzNdckRrjYIAJhUYzf6/ElkrZhg X-Received: by 2002:a17:90a:d343:: with SMTP id i3mr1727777pjx.15.1562697207167; Tue, 09 Jul 2019 11:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562697207; cv=none; d=google.com; s=arc-20160816; b=fddUY/kbq1w8xX0PPNEhMlfFmpgDgSA2HvG6OU9k5LXNhL7QuDdiub5KSWeRLOUvPZ +EpW8EPWEHe8Jdis2GZ5vmMY25vgWTi1AC1HkiUZijBiw6tbLpC572wRMsNlMd8IB95E zi8avzZsJ/eD3SrrK/51XkgnfKk23SUm5PnaL7zIXogrB4A92C+nFf0JL+8g1VKgUtD4 Az5hGp8G3U/JkxxQ9Ss+Q+8FI5mPQchhP+1HBypFXJKLoBedWsDoYo5kwgqp5zVpb7et zzakmz14+lNkMFimlhNfImjWk/SchB1feLd93EC+Tqrk36x0V7IuT5mcqiE5yOHiLxjL +9Og== 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=RNG9FIOsMrNbeAWAGzeZN8uasBHU+JNuQ2nFq46gZMI=; b=rHRMwu3+7m0fTwEt514sJp7k84SN2kQ9I1jL8dslA11FmAk4+w+dO8jLMurKGIEtew 8TmoIcApSEWfVupwaLsGtcKnu7CYIWsKb1VCLlKsHjHXl4HxybBXeu9szbE8ILZOvwwy 2nJ246fDkQlBLIkHjlVc0CHBM2z1YwuyAzjkc6RknyCv5zuiVducE26vyJf8La/CsFKb 5XrPelMOxVpOccsH8aiOrdtYT1jxS2MI/0I3ga52wQrLxterEsAZVLgc8U8G7hEkxoQm 4OunjoCKT24bsu9sx000nnvu4WbMsKI8qknMft+FVKplxE3/npK5m3e6tdySRSzsnfmR yhmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OhgwGTrS; 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 67si12300818pfv.74.2019.07.09.11.33.26; Tue, 09 Jul 2019 11:33:27 -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=OhgwGTrS; 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 S1729337AbfGISd0 (ORCPT + 30 others); Tue, 9 Jul 2019 14:33:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:55124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729096AbfGISdY (ORCPT ); Tue, 9 Jul 2019 14:33:24 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.35.11]) (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 338B320665; Tue, 9 Jul 2019 18:33:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562697202; bh=yHkKoGD86pkN+7stgd+uP0ofZTcNoxDdiAluQJh5XWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OhgwGTrSCVsyY6l35y3Jwar5V8OjWGbU3pdvsAamp+EyeBAqawP4TvOEmNTcy94ro Itr+QH/iIyv+Xr00I/LOdAogXZTUU/JFqTXbdT8OV/JzNPm57UHIpjHz4bj6w5ThC0 P1HfLZyCRM++zp4UoAf94V3S2jHMYnEs5qFysq1w= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Adrian Hunter , Alexander Shishkin , Andi Kleen , Jiri Olsa , Mathieu Poirier , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 24/25] perf intel-bts: Fix potential NULL pointer dereference found by the smatch tool Date: Tue, 9 Jul 2019 15:31:25 -0300 Message-Id: <20190709183126.30257-25-acme@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190709183126.30257-1-acme@kernel.org> References: <20190709183126.30257-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan 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(-) -- 2.21.0 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; }