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: 168301 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4072616ilk; Tue, 2 Jul 2019 03:35:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1PFwpZX1qWDm3VmAVExm0q88lMHBUbzZ9I0Icuo1xHiGQNdESmcOZQw/PonEEpdbptIXd X-Received: by 2002:a17:90a:3544:: with SMTP id q62mr4840592pjb.53.1562063742489; Tue, 02 Jul 2019 03:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562063742; cv=none; d=google.com; s=arc-20160816; b=spGI4tcN5xkPsQNywhEc06ndluS8IDBQvknaL36shOiFvaPUOuSwC+dBIwqq4oOKHR 923+M3+OFyGHJKsXomoZq+Iqlb+zNMqbGYUypxBCWeH8D08wzJ1pjzWzEs8z1EqeabhA XgwJalqS+dliAixhOkU+g2y6EsoJNsszbasoRKdzlSzqDiE114bBXNifyocLaPwYeZkg 32BFaYhRTOAqmkPTWehhNx8du9krlj382IbWOmWSDlkrlTlRmMelnNqwobis0XZxJ6XR C4hU5rPcZWbG4ZAGR/F+/0DX9Mago20VZk+RmIHtoLPY1YhG1BdR7qEgNUvvchG1lwzJ aPSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=yh67xhQ9He3y+H6kFlc9MYFUOr0G7P/w8hL/0JLG7q0=; b=yjEKsFDtjTXvo3YZ9bIDehiSgyWH2GDVCM0asStGer6StbmcZC2blBCPnRb6u3r5XB pkuFc01GRIyZTO/hIPNEikpL6oKtl8RTxEc4a/isGCFg6nRFdjBE0iGW1ljfuqcIoCJl AqqqOS44eq9DIu1W5aHTnzalLWSBmFp4roX+1EL5i7PiK43MrMWefnU4uYgPFzz4CXlo j6NukQoO8a4y3aMVDTgX7MCozGenTfd4r8BaWIkn7TawzxJKHXYwlntm/+hrasfYcBzX Ax7UIHOBHD66ly1d1LYaO3HhZzMCYOf8h7dXBZ+VlwcMaHU1nIk+MJu6cIGJMVmWvqcr 918Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ro1aoZiL; 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 j23si12421035pll.214.2019.07.02.03.35.42; Tue, 02 Jul 2019 03:35:42 -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=ro1aoZiL; 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 S1726473AbfGBKeq (ORCPT + 30 others); Tue, 2 Jul 2019 06:34:46 -0400 Received: from mail-ot1-f47.google.com ([209.85.210.47]:36174 "EHLO mail-ot1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbfGBKeq (ORCPT ); Tue, 2 Jul 2019 06:34:46 -0400 Received: by mail-ot1-f47.google.com with SMTP id r6so16668142oti.3 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=acw3zlPtrxNbEvRSOLBJMM2nYxMjfJYGR//nOqVvkj+cKJBV8816Tm8+XWrp+h/92u ANLTRtMvKtNlhgfqH9i5kDFBZnYL3I0To6GhTLaL98QiOCG2OpDhD87/yOIjat5F5JPB Kcayqo3Dbguhjj+U0ZbfbUBrWaluvnPoua/zhSxNj4HXiMRAnrDqpB20pptvHiNYRkhT Xukafl2vqxLDglqYd+Rdf7ne1no/nMyYUPLPqRVy1cD4Nysw5Np4X5TGtUwk16EZhGKP BS9NvtaP7OTZ75hwq5AC6RjIazRnzBpDE/XQOUnp+QwuJvWVLrGhxysvwpJpkAJBsge5 EAtg== X-Gm-Message-State: APjAAAW2Gv5QTR+j0Vv6YS6NIc3PRIq6kLCeCbwRO4sAv/7LsDMgeSdE yujHRTsvDMkJwg4lH+d1sK3o5Q== 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 Cc: Leo Yan 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.17.1 Acked-by: Jiri Olsa