Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7001934ybi; Mon, 8 Jul 2019 12:27:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYu4YmCBSPUmlmmhOB0sUXqWcbEeciY5jbPiEe7uaiuefEMs1jOSbfVhXa3vlUBywrwr1d X-Received: by 2002:a17:902:6847:: with SMTP id f7mr26405968pln.311.1562614056831; Mon, 08 Jul 2019 12:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562614056; cv=none; d=google.com; s=arc-20160816; b=DHR/5kkJrQvAul3L0DbIwJ9SIlkDvRHdBPgq92PfSlknjV/ciERLMZKrmgRe9f6wUF PfwHiUP9MYUrJlx21jnBonp/zrJlYYp8KM6yVWlBIs0P6tM9zN90FPaTgpfKNTrnfhqW WJFX6RRzJAO/lJ6+22PvjqivtSRI8lXPNDGrYamP76hOzJY+4iHw3S9AqYP0b1QIW2Zf wnE4hoOimLuv/T1vfm6eZjggRJYhR2NGi8sqiZz24VsCmbh0vKp/9S/z2GOfEQt/UTRe 8WSK7UHNVFirG4HF4sPzC3AzfmpZlR85P721FGxMk34lWOmY55PKQjQc8O54vGiP8p3u AZKw== 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 p12si18969336plq.331.2019.07.08.12.27.21; Mon, 08 Jul 2019 12:27:36 -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 S1731901AbfGHOk2 (ORCPT + 99 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(-) 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, -- 2.17.1