From patchwork Tue Jul 2 10:34:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11027623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3565D112C for ; Tue, 2 Jul 2019 10:38:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DCFE2864F for ; Tue, 2 Jul 2019 10:38:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10EB628885; Tue, 2 Jul 2019 10:38:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E91A2864F for ; Tue, 2 Jul 2019 10:38:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=PMH2xnwyr/5SQ3MebKxdKHTO5Tn3UA0Hintwshe4NaY=; b=ZuTX7b6Z+OLsXzMNcUJd8FVCs1 LLubrGFZIycLZOeIOZV0uWVdzqJgEjKOqzYeja5jY8IB+hE1eTzwnaSPukJiucuPfZvdWbnpwIuAW icljDt9AK/fO+kNV0hLjO/QfX/Nh6HhZnf1yn+b0w8SQj2dXaPsDNZ6f9pwfjhz8xctxOjsInNkyw ULXdID9trEXbKorkw0NIkK048oh4KCydCBS4mbh05G9pzvanbQlT3pPhC+KvCDn6uzHT8d+yOmM2C x9RSWAJoI5VnxoagItVdHBeHjIIkGU0+pUFcWIB/FFRKgqR3y7/Jnu2xKLaY98PF/FImZ5klFiDcH 0KQFot9A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hiGBM-0006Gl-Ou; Tue, 02 Jul 2019 10:38:40 +0000 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiG8z-0004Na-3B for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2019 10:36:14 +0000 Received: by mail-oi1-x243.google.com with SMTP id 65so12602492oid.13 for ; Tue, 02 Jul 2019 03:36:13 -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=dQcQ7p8oORqYUmw8MhMOFx6e3+qYvK2rxF9oxDoZM7o=; b=JjPXkNjNwzvim2+CUz73ozuGlX5deuQwPQXRLkI9Fyk/R2nArA59R51YaLMo8npnVO oDx52w/nnl82obHSJkgpF8mTIFXGgbsPgPRY0VhOjMmYjUfylrDBve/OsYv5SO5HwI/t fJtTAVO+HkS47kqFPjOMzwwEZDDJvwgP7lEbyF1Voea5leDzo8xMvT97Wip/cBsMj5HC qb+vN0sL1ae3v1Lp2+ZMoD6/7mRVeEM/HozhAt6Nchk7yTPvTc9H31mPH+gFGlRyx5hx n8EIseeSRFabSWYYZvbYMFwVKE8LJaUpguIJXOkH/Nu/sENoYoO49Zw4nIctWDhGf81L pkfg== 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=dQcQ7p8oORqYUmw8MhMOFx6e3+qYvK2rxF9oxDoZM7o=; b=qYhzhvJ/pzS1xK4T6/u2eL/0wThrt9As+9AE6ifmu9JLpAN5NkRjslyJlFUOiqWOKj VVO3XWq/rrpTiYaOcnBSiCT9WD+xqKrDeJ4P1pItwTzDM3NLdKBX8RXlAJuuFluFuPRD r4NXN4hcc9xEysGkQMzZ2Z+e+Lpg94Ies3aY6dJDy4z4ZETdpCHowL3s8udIx6AsRv71 KqREiiC7P918O9tRpaqC7K1N5XUbOM9loC1+TECGmg0enPU2R0ZyfnjoBDQVXM2XsUA0 y5n+VJ5beTjgpW7Gskl+YKr4GzyB4J6HAgmrZWBqd70XlAPcH+vOOcWiZcXIEw8TfO4n B5Og== X-Gm-Message-State: APjAAAUmzMQ9aLTXZTEOEbWkhMBXZA/f+H+2ogb9uVk51HqaBqu4fmdp SdnnNB7UF198vs/vBWzJhPAmcg== X-Google-Smtp-Source: APXvYqy4PfZ2f8WzbFVNWCQAGxoRu5uiQd1w+JSL9GGeOLIehFvhdbjrx+tZn3DQYJaC+vao4GhoPg== X-Received: by 2002:aca:be88:: with SMTP id o130mr2506821oif.122.1562063772431; Tue, 02 Jul 2019 03:36:12 -0700 (PDT) Received: from localhost.localdomain (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id 61sm5139805otx.8.2019.07.02.03.36.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2019 03:36:11 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Andi Kleen , "David S. Miller" , Davidlohr Bueso , Rasmus Villemoes , Jin Yao , Song Liu , Adrian Hunter , Alexios Zavras , Thomas Gleixner , Changbin Du , Eric Saint-Etienne , Konstantin Khlebnikov , Thomas Richter , Alexey Budankov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v1 11/11] perf cs-etm: Smatch: Fix potential NULL pointer dereference Date: Tue, 2 Jul 2019 18:34:20 +0800 Message-Id: <20190702103420.27540-12-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702103420.27540-1-leo.yan@linaro.org> References: <20190702103420.27540-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_033613_207763_D7CEE580 X-CRM114-Status: GOOD ( 13.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 } To dismiss the potential NULL pointer dereference, this patch validates the pointer 'session->itrace_synth_opts' before access its elements. 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 0c7776b51045..b79df56eb9df 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -2540,7 +2540,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event, if (session->itrace_synth_opts && session->itrace_synth_opts->set) { etm->synth_opts = *session->itrace_synth_opts; - } else { + } else if (session->itrace_synth_opts) { itrace_synth_opts__set_default(&etm->synth_opts, session->itrace_synth_opts->default_no_sample); etm->synth_opts.callchain = false;