Message ID | 20230608232823.4027869-15-irogers@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67ECDC83003 for <linux-arm-kernel@archiver.kernel.org>; Fri, 9 Jun 2023 00:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A8GVDNf1BI6iitC9Ye7WuIwiLliRpRmGfFWSyOUYC44=; b=WKWiET9ylXX7jR Lsf7kEsk+zzO8A7bTzhemLMHIy3Dx/cROuUFCUEKB9gYn5IWz1UYIO/XvRH7XoG1f2MVbwiPenwsC yYimmkkCPCPpygS0Wgv0VHWp/hiuluFNQzK4810yoQtLqKejxHoTEVVS9isNYmTazrr559xq634gs a791fLOuD7qcVtwzmYVsQ0rg+Zt9UTAVRXsJxHrcLVrBPxeB+3in6rzf0QLUou9rBg03LCwn3wMEu c/aJiZJ0q7npiDczKQLCiBvwx89T0ZLP/yKfwbfsLh8EFasF9u7ZliUR2q8Ia8Sg5sXDOLAwhQt2U qUmOr0C9bvl4Zuf9rKiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7Q1r-00B4GD-2w; Fri, 09 Jun 2023 00:30:59 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7P4x-00AvLz-33 for linux-arm-kernel@bombadil.infradead.org; Thu, 08 Jun 2023 23:30:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=y53qLEHCoCMUqnY97AKj5OPiYKzQLuS6tjfhZxn5cao=; b=anr5BMX1ItA2JlTL1fNG+RqAXP WRcl3NkrwGC6Q4x0L47Ltnw7UPycdtj5MFEXUN3uPSfBTTZg5X6gRPbvQANg5bCsSQeORFVkNX5uh 7UVXO93HQycCY4TXHiWRuaWubFGnfP6QZOWM+82f//00Xr0ykrM45uNCIbKYY23hVtrdEV23yKdQd qkUwwQ4t6svOGj2xF4+acuvEwHEIm4/ROukQoWYFxfcRxCF7ZzQpPi38Vg9Otf5LUzzcKOU5jIHhR TfEj1gG5AJXerCunntxtiTcuh9brj2hVopvXkWdh3bjq5VIYG7mISfYhs3h6DEBuvs3bizl+JgFLI Lnk/RRqA==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7P4g-006MqN-0T for linux-arm-kernel@lists.infradead.org; Thu, 08 Jun 2023 23:30:00 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bb39316a68eso1563071276.0 for <linux-arm-kernel@lists.infradead.org>; Thu, 08 Jun 2023 16:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686266986; x=1688858986; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=y53qLEHCoCMUqnY97AKj5OPiYKzQLuS6tjfhZxn5cao=; b=BWtzVLrqKoYJkSLm4xm24dV+YG4tQHyElrZuiGFxyxxUpwkdM8hK6Yhml3VsH4z5Z6 3MLwEVGcbfnE2o12xZXJpiEq2AyD0GGwb5fjRx6qe3PK/6uXhHcU+Vp0hL8QMOcSPUHb VWcfJCljAE445drlVaMjFp3LzmE+ldlRFKk5DiHtIgvxkMWoNAbzNMvRu2c1v6ZJlXVo Q/SvbwhBi9qb5VEewCYKaURAKA/gr26s2zE4cVmEEL2VuKZ9aXIv+BNsUDOrrvzn4QBG MIw9GfUgPmu0kUHOCZ6Vnpn7bqh4rUXtUhyfvjO/wuKjtWszxn3htihXp+h2u3rbkzVR Qs8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686266986; x=1688858986; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y53qLEHCoCMUqnY97AKj5OPiYKzQLuS6tjfhZxn5cao=; b=l9WsGnMkrFm9v4966Vak4Yj40qC6OLKjrRJ4dfby2C6ERuM3w3G1UuaE7tHtyMR0VW dNUyd45PDZkeewodItmLZpcdOqoJdHEdFzhBhZI+a22S3q8yqgheCqXDQmq/MymZI0/I si3bLsX5Pd3sqH8/o7gqC1vVP7Lixc8cQoeU2KAC5oFGxufLkLkIuxGL/OnCPHQQGAm1 Lsn4x3Tpg7JaPMjFsf2vZ0jAdCyRb5yDBd/kpIvZQ//wypXvYlmzhVC2Bp+Gjw5EL6wE Gz09VCWFLyRcOlZ+OU3efxCSuiLoASAoOmoovXOd2dxg2vEnneyyr6ABIs36B6JjOhHI JBNQ== X-Gm-Message-State: AC+VfDxFubAn1jM/DQo1BxfFSYI4LGTgp431PbvHtXZHI0LhFn2leCDv mxqm1whvZWLI3nP2CzczyCTgYFCfDodN X-Google-Smtp-Source: ACHHUZ5DzYfT4hI1PXDA8oBQEX/6jVDDSD3WmZq420hLxCfPkjKadqGgW4rFwIrQydNs80FcrAShZHWOaoZ8 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:c3e5:ebc6:61e5:c73f]) (user=irogers job=sendgmr) by 2002:a25:abb2:0:b0:bad:14ac:f22e with SMTP id v47-20020a25abb2000000b00bad14acf22emr347019ybi.5.1686266986565; Thu, 08 Jun 2023 16:29:46 -0700 (PDT) Date: Thu, 8 Jun 2023 16:28:11 -0700 In-Reply-To: <20230608232823.4027869-1-irogers@google.com> Message-Id: <20230608232823.4027869-15-irogers@google.com> Mime-Version: 1.0 References: <20230608232823.4027869-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v2 14/26] perf python: Avoid 2 leak sanitizer issues From: Ian Rogers <irogers@google.com> To: John Garry <john.g.garry@oracle.com>, Will Deacon <will@kernel.org>, James Clark <james.clark@arm.com>, Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>, Kan Liang <kan.liang@linux.intel.com>, German Gomez <german.gomez@arm.com>, Ali Saidi <alisaidi@amazon.com>, Jing Zhang <renyu.zj@linux.alibaba.com>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Miguel Ojeda <ojeda@kernel.org>, ye xingchen <ye.xingchen@zte.com.cn>, Liam Howlett <liam.howlett@oracle.com>, Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong <yangjihong1@huawei.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Changbin Du <changbin.du@huawei.com>, Ravi Bangoria <ravi.bangoria@amd.com>, Sean Christopherson <seanjc@google.com>, Andi Kleen <ak@linux.intel.com>, "Steinar H. Gunderson" <sesse@google.com>, Yuan Can <yuancan@huawei.com>, Brian Robbins <brianrob@linux.microsoft.com>, liuwenyu <liuwenyu7@huawei.com>, Ivan Babrou <ivan@cloudflare.com>, Fangrui Song <maskray@google.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_002952_926184_89F900C2 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
Fix memory leaks (was reference count checking for thread)
|
expand
|
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index d7c99028c6e6..d96e5c0fef45 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c @@ -735,6 +735,9 @@ static void regs_map(struct regs_dump *regs, uint64_t mask, const char *arch, ch unsigned int i = 0, r; int printed = 0; + if (size <= 0) + return; + bf[0] = 0; if (!regs || !regs->regs) @@ -764,7 +767,7 @@ static void set_regs_in_dict(PyObject *dict, * 10 chars is for register name. */ int size = __sw_hweight64(attr->sample_regs_intr) * 28; - char bf[size]; + char *bf = malloc(size); regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf)); @@ -775,6 +778,7 @@ static void set_regs_in_dict(PyObject *dict, pydict_set_item_string_decref(dict, "uregs", _PyUnicode_FromString(bf)); + free(bf); } static void set_sym_in_dict(PyObject *dict, struct addr_location *al,
Leak sanitizer complains about the variable size bf allocation and store to bf if sized 0. Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/util/scripting-engines/trace-event-python.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)