Return-Path: 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 31747C3DA6F for ; Fri, 25 Aug 2023 02:41:12 +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=yBlhoWkLSLLt2r86MmUMZBHy4DSwvU+FJcW4cflI1Gk=; b=vZevPubdv4BRyV j9wlYUtk7By905aMtzr2zH+4BjVNkIvgPBnuw6xgKZApilcKC0L3S2lsnbil8Uurofg+GDE9P1eyj z0ut0aXrM8wM4Oudi5kfKoaI5bWGhvu3Gj9BrGuqJYTWC+jolAgmcy34pWrks1PdmWh2Dn5lNN0xe JNK0ut4VtEl8ZbECseVspZgmX6ov2SKqUZ+l9JWK5Rg8tlChSR1EsV4qNwok/NUrEnJDyJLwU7KYh SmpqsdYHlsn+RAk7d1KJVGLdgyrUrFISSpfwsgdd3umfiMPPHIpM6icw5TQWagEW4bZdtMLL3vNC0 Hx3PiWqj57oHQbu4hsKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZMke-0048O2-0B; Fri, 25 Aug 2023 02:40:44 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZMkY-0048Lk-1X for linux-arm-kernel@lists.infradead.org; Fri, 25 Aug 2023 02:40:39 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-58c8b2d6784so7171437b3.3 for ; Thu, 24 Aug 2023 19:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692931237; x=1693536037; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=BHXteoJsO5CjisE3iWmyoU3o62DiyCouesqp1NV6ZaY=; b=aM1+/Q9/kqw9FPRt+ilUC2t7yHLdncPzCcyJOdfOPAzDkrfOyw4un0h7kWm/0Qss3d NZFW3A2SdinUDE2lpqWfXf87L12zQUGFk4HnP+F43itYhRV9t8p4sPKvIxpLO4O1e5ry xWTvly0fX09Jg95DitgN79YkII2+4qbIpeeQQLydHeV4IFgM1g6nevB8+LkEG1TR1gyo IgsiBX1y1/dn65Bvbkbn14tFgtJtGGxxK0KrXwN0HheDF/LrN7dc2LyhkLbEGu0uyqK1 VEVzzuFW9e/yWmLZP3luTRDeMbdMaF1I55SoCgD1dSo+nZFJUAJiI13BEx3e16PI+zJV sRTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692931237; x=1693536037; 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=BHXteoJsO5CjisE3iWmyoU3o62DiyCouesqp1NV6ZaY=; b=FDfTftWdZxTd+XCqZkZsxZtpcQVoT94ucYg/TELnEi5yg8dkkjQstEAk4a+N85f9t5 BoNbFGRHDTgaq/EYpaY91lmK9SZGZWww1dnHCl0jGm5FqTH0euve1cGeqnpRSo7apdFH M/sl4xHLuqwHiDgBWxLHc0oR/oVq+j4f6y4Agh++bexpWRkpxPQEYpRhKeUmihLtaLuO AAytkOsb4Z4TvvQosncUfHtlhfVjC3J90UoKWC+lSLXlco8ucl4PXd9yjsLEFa1q58pA FtmgIn4iMymhzVaEle5K4c8BgOk64mPTK7OXwlHexyef3NoHDNPbfHxAweI5GnrXtIzq YRLA== X-Gm-Message-State: AOJu0Yxa9mY0im2wpJUxwL0ceeuXO7Acg9DgeYlWGdzhmIElabygKr1b Vb4hLheUH32y/84BvtWEawlSS/Z6sgd+ X-Google-Smtp-Source: AGHT+IGaNkQKvYICmjYwbFYZkcVjwo9/uyNhIHNgKwBwkDBYJTIRQcWeE5epFd3NZyNnRo3DSrMjLPSFkFEv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:449e:d47b:bc6b:cb6b]) (user=irogers job=sendgmr) by 2002:a81:b660:0:b0:573:5797:4b9e with SMTP id h32-20020a81b660000000b0057357974b9emr373461ywk.1.1692931237087; Thu, 24 Aug 2023 19:40:37 -0700 (PDT) Date: Thu, 24 Aug 2023 19:40:00 -0700 In-Reply-To: <20230825024002.801955-1-irogers@google.com> Message-Id: <20230825024002.801955-5-irogers@google.com> Mime-Version: 1.0 References: <20230825024002.801955-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.rc2.253.gd59a3bf2b4-goog Subject: [PATCH v2 4/6] perf pmu: Make id const and add missing free From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Ravi Bangoria , Suzuki Poulouse , Kajol Jain , Athira Rajeev , Ming Wang , Huacai Chen , Sean Christopherson , K Prateek Nayak , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Li X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230824_194038_518924_936EABB4 X-CRM114-Status: GOOD ( 16.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The struct pmu id is initialized from pmu_id that is read into allocated memory from a file, as such it needs free-ing in pmu__delete. Make the id value const so that we can remove casts in tests. Signed-off-by: Ian Rogers --- tools/perf/tests/pmu-events.c | 4 ++-- tools/perf/util/pmu.c | 1 + tools/perf/util/pmu.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index 94937378647a..eb243392c0f4 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -684,7 +684,7 @@ static struct perf_pmu_test_pmu test_pmus[] = { .pmu = { .name = "uncore_sys_ddr_pmu0", .is_uncore = 1, - .id = (char *)"v8", + .id = "v8", }, .aliases = { &sys_ddr_pmu_write_cycles, @@ -694,7 +694,7 @@ static struct perf_pmu_test_pmu test_pmus[] = { .pmu = { .name = "uncore_sys_ccn_pmu4", .is_uncore = 1, - .id = (char *)"0x01", + .id = "0x01", }, .aliases = { &sys_ccn_pmu_read_cycles, diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index eb42f9830be7..b92dc7237f3b 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -2056,6 +2056,7 @@ void perf_pmu__delete(struct perf_pmu *pmu) zfree(&pmu->default_config); zfree(&pmu->name); zfree(&pmu->alias_name); + zfree(&pmu->id); free(pmu); } diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index e90169ab3dc2..73965f208009 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -49,7 +49,7 @@ struct perf_pmu { * @id: Optional PMU identifier read from * /bus/event_source/devices//identifier. */ - char *id; + const char *id; /** * @type: Perf event attributed type value, read from * /bus/event_source/devices//type. -- 2.42.0.rc2.253.gd59a3bf2b4-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel