From patchwork Mon Jul 8 14:39:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 168657 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7252738ilk; Mon, 8 Jul 2019 07:40:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlsM6vh3H6CA7ltgDGIEwnnbzPagmIWvL+T1vHiw2SnCFr6FXTfEHeD4wJu7+EyJgxGHfC X-Received: by 2002:a17:902:54f:: with SMTP id 73mr24862688plf.246.1562596820773; Mon, 08 Jul 2019 07:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562596820; cv=none; d=google.com; s=arc-20160816; b=VmknWRqu4bkZffjufakWczau/YKp8INqrWtkOH6hpG5IytYHM1NjJX2vJizKA9wJ/o iY/xMCEavfUJXHfOv9P5X8x6LI1yvaWrjDcPRAtnOS8Lts3kBMj3+ykd2uazrmOdONnd t47ZbM8UtT3YZPtzT81icUAgW7YZpKSu1RSI1hZblpnBSBeGXjZswavJfr+BnUD3m8vt rtDOGFCo92EEWypJPrwJnxDwhel4euireEnfFu16uggHLNhl2D6yiUO23YaYD0Z4yGXU MdN7cLyiS4Ny6GpSAwrRUEzk/sDjJlLU3ZZ/4u4D3YKnsU4zRKR2unLuauigh+QIZYHH 80Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=iIj/D2uFckhktV/1D81+BNHiSe7rGxGISfmtPBSrlSM=; b=Mp3bprZztTUZUBl0i3zSzf65nT4tIGjod+DWWfaTRAvitZ3ZZ7/kk+6MXH7CEf7RQs 2dTWdmQW+ZcKRpsGxHwC4IpPe7NaVV2WWVjy2dhcjA9MYuyMRNVBsiNCO1AUF6QeQwir I6OzpLe/7UlLyyh1xsw037Y8m/XEySYQpelpPfsxVdkJ0Ze7AHKTsojpVVDaprd1BkxF TKqF5ZIsaIZ1alS4PxnlQ3IUw6xxSOmxzbH0dSPa1LiTuWE7wjX/PHH9ob8x89S38+1a EuLOyHDz6NkYlA46YJrzGWIDOcfFliPeGDFFox+2Ampdc48+GBsK6gRASnAMD8Lxt79g TJ4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C+MArnBQ; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si17867293plo.384.2019.07.08.07.40.20; Mon, 08 Jul 2019 07:40:20 -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=@linaro.org header.s=google header.b=C+MArnBQ; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731870AbfGHOkN (ORCPT + 30 others); Mon, 8 Jul 2019 10:40:13 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:44786 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731855AbfGHOkM (ORCPT ); Mon, 8 Jul 2019 10:40:12 -0400 Received: by mail-ot1-f67.google.com with SMTP id b7so16389189otl.11 for ; Mon, 08 Jul 2019 07:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iIj/D2uFckhktV/1D81+BNHiSe7rGxGISfmtPBSrlSM=; b=C+MArnBQMr2fem13xnS9J64lNmtz6x3eb264CDVGZm7lK3pxHAy8901qu3ZTI2HIS6 7K9WLnI/UgnLLE1IK0Nh+pHlhLXmB4gPUEqugQmc+xsgLxMQ0G8jeB+9KL1O/cfTMvXt erNEljQYc3VzgMUZRXI+YJ1J59KILFnMJ3P2X1PNJo3Nx/w2yYFWGaccpDUTST0tS3yU mXnMUWw1nnC/DFX/QkIj/wO9Sc2SGyy6oYCYidmXzXXV4Z+KDev9igsREiqaE5fOpfx0 DwfbUepPKKEmN0tnUtPOleWgPURufqT8O7xB3E3KtQGRrDjQ3fFnI4EDjpeLJ4WO90dI zo/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iIj/D2uFckhktV/1D81+BNHiSe7rGxGISfmtPBSrlSM=; b=gImuxAI2nWfuOeI/xrbI1rUMW62d/XccnHwFQ2InuipXa7oWNtxKf2MfHltfsc6AC1 4+XcTGCN5F2nlAhK2tpipW0KxdNtRdMS99G3gUTtMhW91HCYYxTDc4cgMyrNh+98igML PzBFxr1UfmWNcxj1D+0cvAQRTszbs1RDABuAyY4vE1kubnaT4iWlAU0WknpJQa3lfBdh S6IknQtdx1aruXEjk1jSIhC3s5H/52thoGSBY944yuMkjUdLTit94iFAmhuvctsDeSJl uSLXdqCZq8sLRnFwSrpJtB55xCJJSvf5qf2LWDuWkwINTu8D37Jub/ZGB1L8664Td09D QuUA== X-Gm-Message-State: APjAAAWb50aED54qRL2jhNt8JlHPyIJnpGYoJ5YVBNROrnXQ14GySw+w riK8lzBJ40ES5cvoVFrkxIB8xw== X-Received: by 2002:a05:6830:18a:: with SMTP id q10mr15142642ota.114.1562596812197; Mon, 08 Jul 2019 07:40:12 -0700 (PDT) Received: from localhost.localdomain (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id x5sm6386021otb.6.2019.07.08.07.40.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 07:40:11 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Adrian Hunter , Andi Kleen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v2 2/4] perf intel-bts: Smatch: Fix potential NULL pointer dereference Date: Mon, 8 Jul 2019 22:39:35 +0800 Message-Id: <20190708143937.7722-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708143937.7722-1-leo.yan@linaro.org> References: <20190708143937.7722-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- tools/perf/util/intel-bts.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.17.1 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; }