From patchwork Tue Jul 2 10:34:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11027599 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 C60CF112C for ; Tue, 2 Jul 2019 10:35:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8D352886C for ; Tue, 2 Jul 2019 10:35:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9946A28891; Tue, 2 Jul 2019 10:35:09 +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 92B7A2886C for ; Tue, 2 Jul 2019 10:35:08 +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: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:In-Reply-To: References:List-Owner; bh=1I3iGFLK07Tm0dyGqACu/WUYI+TpJdioF4GJ12CPayI=; b=PUT NwhIb+/LnXKq8awOMJaMB5Oe0TbY82tXPxTin89Q+giqrhqoapxS/l1SkDCl0xOCK8LxxssmAwYlO N/2rlBR7MPlianOADbhRKpgZw0XpfXXxXCd/Db2iYqAw0N+nBpBjA80kN43fu+Eih7ixl2t8UJtcB nDKLo/XfvZivW6ybNYl7uiM8MHnCclXtJTbRLItXLYc7t92UnjHsYeVZOQdmZVcjRJlVwPfgQGu02 SguDkvxrGxZa1d8EyGP/kW6JgQDSgYxpLCZ+f/RN8MrWAdufJWy+rwo/4UwNDXMAYF98JViOgDiJW lW+iQHeH4gKogh9t0hfnpXfuWLAYGug==; 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 1hiG7f-0002F6-0q; Tue, 02 Jul 2019 10:34:51 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hiG7b-0002Ef-37 for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2019 10:34:48 +0000 Received: by mail-ot1-x333.google.com with SMTP id q10so6702992otk.10 for ; Tue, 02 Jul 2019 03:34:46 -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; bh=yh67xhQ9He3y+H6kFlc9MYFUOr0G7P/w8hL/0JLG7q0=; b=ro1aoZiLphx5ycNYHWZ/hgdw2qioib3lO2AZziumfOIaMeEw6KWC4sZ6B8gnbf1KJ5 EUwfsAVZCki/ptHXFJ4Djy/3fjdSUjT8fJOOWZ1CnYePdlhaC8j6AMXvhmtT7W8GyMzp Y+ww71ZYjgY0drfqEjpWvHlVUE6L0dO5MDtPmO+Xl7pnCEK/QYIIZOykA9UXFkzL20O3 tIEf3G4WALElbBB96b59GPnU/I+yf8J6ci66dTxRaLAyXB3K0GvS6Jf/FdA6qeeC1/ZX S0OAd8HIfgBqG/2R4MYbXrZKm4l9xDFAqGHZPsywSswKeUEpTs0GwOeY0qEYDlXXUB49 F+xw== 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; bh=yh67xhQ9He3y+H6kFlc9MYFUOr0G7P/w8hL/0JLG7q0=; b=OyPrHsZ9Y/C93W1EOJsHeUbbgQ7fK+WCDuwU6KJ+iZmt1chTQmOYoyC87opoDg/vu1 +Bz+AnwKYnRwY5JZQNoEDUVb8xOY0vXNDcKhJCGVzAnM8XvkhjguYLwBz+PqSUbVrL1P MHuk/70fKcuMEN7k+8Zc02qNEOCexg75HKcqUXHk3z+VS+OdD3J0t+L0UnSGkBUSBnqi BTuc1rnRrs8VwGXUStJXiGCkILeeaJDtS6kXB7GrTPYbUXXtgT/m5ga1l/xYRNROiT48 Ne57ingw2Jur+qa9zKl+tytJgxmzrn7gtM/g4O2rFCo/wBoL954YUx8YAe8EUG7RiHOY dGHQ== X-Gm-Message-State: APjAAAU/aZ4Com377lAUVjOpeDJWFBP0PGKkCJHPVsd7USWch5syZWMm Bpvocyxxi3qKlRmK0/HQogNS3A== X-Google-Smtp-Source: APXvYqz0F+LZR7w7Za1W/0SVbgXXPE/RHIsbrL7w+y9m0fjgqj+wEs08VL2EYmN2ulht4JSPGawjew== X-Received: by 2002:a9d:eb7:: with SMTP id 52mr22187581otj.70.1562063685693; Tue, 02 Jul 2019 03:34:45 -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.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2019 03:34:44 -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 00/11] perf: Fix errors detected by Smatch Date: Tue, 2 Jul 2019 18:34:09 +0800 Message-Id: <20190702103420.27540-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190702_033447_142103_C657378E X-CRM114-Status: GOOD ( 12.02 ) 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 When I used static checker Smatch for perf building, the main target is to check if there have any potential issues in Arm cs-etm code. So finally I get many reporting for errors/warnings. I used below command for using static checker with perf building: # make VF=1 CORESIGHT=1 -C tools/perf/ \ CHECK="/root/Work/smatch/smatch --full-path" \ CC=/root/Work/smatch/cgcc | tee smatch_reports.txt I reviewed the errors one by one, if I understood some of these errors so changed the code as I can, this patch set is the working result; but still leave some errors due to I don't know what's the best way to fix it. There also have many inconsistent indenting warnings. So I firstly send out this patch set and let's see what's the feedback from public reviewing. Leo Yan (11): perf report: Smatch: Fix potential NULL pointer dereference perf stat: Smatch: Fix use-after-freed pointer perf top: Smatch: Fix potential NULL pointer dereference perf annotate: Smatch: Fix dereferencing freed memory perf trace: Smatch: Fix potential NULL pointer dereference perf hists: Smatch: Fix potential NULL pointer dereference perf map: Smatch: Fix potential NULL pointer dereference perf session: Smatch: Fix potential NULL pointer dereference perf intel-bts: Smatch: Fix potential NULL pointer dereference perf intel-pt: Smatch: Fix potential NULL pointer dereference perf cs-etm: Smatch: Fix potential NULL pointer dereference tools/perf/builtin-report.c | 4 ++-- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-top.c | 8 ++++++-- tools/perf/builtin-trace.c | 5 +++-- tools/perf/ui/browsers/hists.c | 13 +++++++++---- tools/perf/util/annotate.c | 6 ++---- tools/perf/util/cs-etm.c | 2 +- tools/perf/util/intel-bts.c | 5 ++--- tools/perf/util/intel-pt.c | 5 ++--- tools/perf/util/map.c | 7 +++++-- tools/perf/util/session.c | 3 +++ 11 files changed, 36 insertions(+), 24 deletions(-) Acked-by: Jiri Olsa