From patchwork Mon Jul 8 14:39:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 168659 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7252915ilk; Mon, 8 Jul 2019 07:40:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOgXIN9HAuS86aHAGi9VLC113e6KRrKP0RILxrvl/yELR60apiIenOIs+i6f2qiQUfeLht X-Received: by 2002:a63:6ec1:: with SMTP id j184mr24562023pgc.225.1562596830386; Mon, 08 Jul 2019 07:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562596830; cv=none; d=google.com; s=arc-20160816; b=gK+/l7h74LyD8bTSUubkeXy9O/xcQU1XFDee9OlEt7Di9/cFwOrpTtXA5ttwoNbOtD UOkohUlBLcOAn7T1kCao1gAXTh/NVevX/bKQIrdwLri1EvUyl/BcOkdPbiHb3d1slyTh G1wuy6qwfr4R6sXWmz7aQWoVKC4vBWcE93IKx8j9Bq5RPb15iK6NYpHTm27UFYO89Rmt ++uhO2XEdAYtSCRVAn03/OMyktnDuVCSFFEV+wJlZ9ZGdKjPnnrFiQkgGyV8/I+KVH23 eC0ymGcHAQfK/5BXd7nhHgnSJw5/2mXccySALfh/fKeOTj6JleYGvKxbiUxGMqMUppHY B7hw== 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=CCSoHq1Uo4IBnCwfeuA+GvIGXoY8z0TTGOk4Tw+sVOA=; b=meV2Gs3SPGKokkjU06DcZvv1YJgLstSmwElaTXUPyht/JtresNn0fRu5cH8I7ccF0g aD3wGP392nP9CQaKLUtnr99mO1Np1WdyrzPYmhRLIPXxl4/x4OzhVUsw8WffEP79msnt ZsLrOymbmRKHlXSEl9Ci1WDv21EwrC7HmUG8dgryFJEP6hwYF6IlgAkgkbps2706X6tA 8OrgI1kr69TbZYK9ZQxyPNbDEzIY5KIl4jEr1BaA4NUo23HQrQdbagRaIjNd60KD7qTA W2nHsFU8VICi1s4GhI/R3233bMp2jZCi98NaFVg6poGuJqQM/az6G6srdc/tiOAQ7Nmv HOlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rMnUN1r+; 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.29; Mon, 08 Jul 2019 07:40:30 -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=rMnUN1r+; 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 S1731905AbfGHOk2 (ORCPT + 30 others); Mon, 8 Jul 2019 10:40:28 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:34422 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728823AbfGHOk2 (ORCPT ); Mon, 8 Jul 2019 10:40:28 -0400 Received: by mail-ot1-f67.google.com with SMTP id n5so16460014otk.1 for ; Mon, 08 Jul 2019 07:40:28 -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=CCSoHq1Uo4IBnCwfeuA+GvIGXoY8z0TTGOk4Tw+sVOA=; b=rMnUN1r+KicSBHv/XyAGYU6dbXI3N+TcAG/o+Ydxv13ZCBB0c/O2uu9G4vqrLCytct AEKFHYY+SHopfy3uStEBvIMEspHQMmadm9wEmnta9CgMRDdfOnpwGL+PB2/POmpXHUru /MlsSUF/JzCed/TIDJCNcEyJODeNFhMRwfZWmGaKDJfrVJgMDTYz0U8MLjvjQGJDDUsK kaqgF3izPU2FROV8J+mfY6t97vifqIqb/sJvvFV9+XMLcxYIMSnX9vQhtJdxdxWjDUXJ NPnoBwSTkxC7AmqTwW6gwUncSzbtlw0O7Aaaj9ZmAZA8Uczsbth2wNfWlo5oh6QrJWYq iW9A== 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=CCSoHq1Uo4IBnCwfeuA+GvIGXoY8z0TTGOk4Tw+sVOA=; b=LNVA0AWcXVtfDLeuaNa5L3BYhQTotr7tXnEpmplGOzV9E3ClU/L6B0ymwqQ140UNyf QkTjJNAW3K5zC4AiG0TQRKiPsGWDf2quYRf32RKQyQeCFU5WOjiAmNu5ZI2T/loHhvR9 wfiQLN/awEMPf/UNeNgul2KOJSSNvJSH1USQNmGZJ6DfbV881ZczHG59TWsUDkuGNmRe VK56D6+UiJq/zeGLCTPMhdPeGUU/nbMbvvHA4pBa/VrOHLYV82m1+L6XAR/TM9QHEz2c gpw1QXQqhqbF7j8TprJJMF7BGgu6zavxgM887SqvHuJpBECyU55qM/dY+ST7b8kj2FYI fWcA== X-Gm-Message-State: APjAAAXOaNqjbz3utsklwBCVmXDqBq1DU9G3bsF5TpcSb5r33cVXzRh7 /rGkHMmB6DUDca1KViS2cI2C7w== X-Received: by 2002:a9d:4b88:: with SMTP id k8mr9349423otf.285.1562596827664; Mon, 08 Jul 2019 07:40:27 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 07:40:26 -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 4/4] perf cs-etm: Smatch: Fix potential NULL pointer dereference Date: Mon, 8 Jul 2019 22:39:37 +0800 Message-Id: <20190708143937.7722-5-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/cs-etm.c:2545 cs_etm__process_auxtrace_info() error: we previously assumed 'session->itrace_synth_opts' could be null (see line 2541) tools/perf/util/cs-etm.c 2541 if (session->itrace_synth_opts && session->itrace_synth_opts->set) { 2542 etm->synth_opts = *session->itrace_synth_opts; 2543 } else { 2544 itrace_synth_opts__set_default(&etm->synth_opts, 2545 session->itrace_synth_opts->default_no_sample); ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2546 etm->synth_opts.callchain = false; 2547 } 'session->itrace_synth_opts' is impossible to be a NULL pointer in cs_etm__process_auxtrace_info(), thus this patch removes the NULL test for 'session->itrace_synth_opts'. Signed-off-by: Leo Yan --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Mathieu Poirier diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index ad43a6e31827..ab578a06a790 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -2537,7 +2537,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event, return 0; } - if (session->itrace_synth_opts && session->itrace_synth_opts->set) { + if (session->itrace_synth_opts->set) { etm->synth_opts = *session->itrace_synth_opts; } else { itrace_synth_opts__set_default(&etm->synth_opts,