From patchwork Tue Jul 9 18:31:20 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: 168761 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8897330ilk; Tue, 9 Jul 2019 11:33:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzi/Bj1pgyccUijUlZU/KLr7TV7QgNdN3NJVVHilqb8mlkm8/vuvaoydCQYfMr+14fzpf+y X-Received: by 2002:a17:902:6a87:: with SMTP id n7mr33383893plk.336.1562697190630; Tue, 09 Jul 2019 11:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562697190; cv=none; d=google.com; s=arc-20160816; b=jzQ/Qz0brvOfSGR8NEFcCAED4KCfsFmgb0KEs32KlQCXzL0JFSSBjiTKpRh6fhYZIS VjaxEwDhqZDG+M9QirgPjO0HlF32dhxVATBF2CDMAiGRors9QJYgr8lz/CwFiv7+X36d CM65UD+jCCIuNIsBLv8mDH8A1yMZxgz6YZAtOBlw/rSzYyk5F5mvPP1QneQ5k+M5EpIm G9vBUusDFmklKGNz/q6OyK3oZ3AT/ah4Pam1FBtsbQCYY7MwqKM7zo2c1AYg3Am08cvN uyOeFLIKLccw4UECXrhv7wARIwa6WUKXZxS9ghtwBNIOsXXYWQobVBFg0VIi+2X7TePg UM3w== 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=1Tgxq9vSNl+U3rCnP871jYqkQXZuRsJvvXFtdLKzUjI=; b=g/gWiVf5wFnNUQ/4cnYs+Dt7ZG3FTo3qdr9j8lsYIoS/kYl74bEnbJ3SJeN+zVFv9y kaKHDczPhTKhxk7pdX8UXlsbHT09zwxG3nqqmhzfjOsynxTjgThwd2nw8TqN2j+g2qbC C22oT/2lcaz+0su39FP5IBrmTJL3Mv78LlGo1Hk14OJ4t1qIK0tq4Bg1XnZJ7cCyMgt3 qA+N85CjvAUcgqBi19IECJVw7TaxzyZDTvwnrcrM76RtHjGwT4THQoKKFGqygBFDCdsj OyeKyoBseAUnO0NW1AtNIZ2LD/H3UlgL6pUF68Yfsy66JRwdpub5TQT+nNMswNgJlWPl 9AzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qNlo2WDs; 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 x185si24921602pfx.243.2019.07.09.11.33.10; Tue, 09 Jul 2019 11:33:10 -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=qNlo2WDs; 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 S1729281AbfGISdI (ORCPT + 30 others); Tue, 9 Jul 2019 14:33:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:54756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfGISdF (ORCPT ); Tue, 9 Jul 2019 14:33:05 -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 E8EF720665; Tue, 9 Jul 2019 18:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562697184; bh=+AHHhdCKUtduEQJ0K9mVtwS+3cT8oze/CNUH/7f6WcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qNlo2WDshInz0LxZHziyFOQ7IticF2B5seQoqdwNEkGwXb7NjkejRO2Kx6c49thQo rBHeqnABe6q9slbHT66Dfoz0U9uQScNpFgsMSgWevK8Mhyzpo18byI7gnQSeLeYlFt ontlmBoLOc1jbLxNSxMPktzZFaxgzFZLp4R7aj94= 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 , Mathieu Poirier , Adrian Hunter , Alexander Shishkin , Andi Kleen , Jiri Olsa , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 19/25] perf cs-etm: Fix potential NULL pointer dereference found by the smatch tool Date: Tue, 9 Jul 2019 15:31:20 -0300 Message-Id: <20190709183126.30257-20-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/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 Reviewed-by: Mathieu Poirier Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190708143937.7722-5-leo.yan@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/cs-etm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0 diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 508e4a3ddc8c..67b88b599a53 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -2538,7 +2538,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,