From nobody Tue Feb 10 15:43:25 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24E36C3DA6F for ; Fri, 25 Aug 2023 02:41:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242195AbjHYCkw (ORCPT ); Thu, 24 Aug 2023 22:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242074AbjHYCkj (ORCPT ); Thu, 24 Aug 2023 22:40:39 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C583D1AD for ; Thu, 24 Aug 2023 19:40:37 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-58fc4291239so7438567b3.0 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=aI8F10oMLIpmleL0oYfcxTY3jL6orlC2XxoaVWZY/UPBpS8x4+iB/SO8aj20Sw1/Ox qIcBldOm+YUh36fRuKA1bbJeH1+DhFg9BEVO/lsPBk+rcHY1ClgTdx4Yh9Ngn6Haa9HY /Nc4to7jJB+dTTWjE1lQsho+6f5HlbLtUQ7DMw6yqxtkmvSyJLhp3syDqb4uFjQ78OmL pd3mfQRteNXfdWRSM3dO8PCcKXsyT1dIM83uBUyqehBzCYS4df8UQ0VWz1qeJdevYYwu aWYi8X1LwuOcrYKffzBs0q0zTxTsdFr0Bm/tIyEU0pC10idaEmhPiqPxDjyC7to3zHco ytiA== X-Gm-Message-State: AOJu0Yx3n4+vrwA147yc07NCg37/0sDw78LcNhOP+4LIcjwtCg4y1Kjc 0PXH/qfp8F+4xlUyoJB4HyjYWqBHHtQR 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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[] =3D { .pmu =3D { .name =3D "uncore_sys_ddr_pmu0", .is_uncore =3D 1, - .id =3D (char *)"v8", + .id =3D "v8", }, .aliases =3D { &sys_ddr_pmu_write_cycles, @@ -694,7 +694,7 @@ static struct perf_pmu_test_pmu test_pmus[] =3D { .pmu =3D { .name =3D "uncore_sys_ccn_pmu4", .is_uncore =3D 1, - .id =3D (char *)"0x01", + .id =3D "0x01", }, .aliases =3D { &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); } =20 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. --=20 2.42.0.rc2.253.gd59a3bf2b4-goog