Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2077335rdb; Mon, 9 Oct 2023 11:41:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHukdVzFOp3fEhYXlyxUs1UPWx6pPSfCmlm12KKlEh/EPVpsn4AisfpddkvDQBWwF+6HdBy X-Received: by 2002:a05:6a21:788a:b0:15c:b7ba:ea44 with SMTP id bf10-20020a056a21788a00b0015cb7baea44mr16371483pzc.60.1696876901708; Mon, 09 Oct 2023 11:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876901; cv=none; d=google.com; s=arc-20160816; b=TsPg0ovBsg/n9J9ehEuSEBY0tWTDJ+y8AYuyiLDK7Ybr9cNdDDJz3YtwUv7JZPOVaY BbaMy76QXWdF0t/3JgrfOMl0qaXxwok3CUzjBxpPejQrAi7oXxMRAH654XWoqymLel3J eNCactcTvEHMN6XbHSLq7nzMI9AmoVgU56iDbu+lvIYLKTd4YLUVHALa3jpJ57wH0zWv wZHt3uKOL1QLvTcqAqOL5c6z5h5uJWSVh7QHRzAeUDlVKHgJXi5ioTb4jg4Yvuow0kmI vpdLWGF8RcKD7tad2c7kGGqnj51ZBZs17kBE6nrEdTZe8JOXmkfJWZSLAjUkWkY6GOm1 3Nwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=wfL4FLU++s9CKjil59t6XdpqiER2jatUC+zl7nbhx6Q=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=M4JLWfINb0L80h6vBEtK/gShVthIioT0NVNYj8GI1OkfO5YvVNnulaDaJNQBQlCiTv +veO4XqCOQuI36xPGslxac4xqZYPBNGxc9OmNlUm+l1x0rFWVWXObBYA8dJVX3gCTDhb nM/UqqmdwnEsJ62vhFjgzqyNi//RdfM2cVYGz6LcTTyMeJCZTTc8JMr6kLdqG3Yig9yK +borzwElDzDQBqvfYSF2j9SDOTQZO+YmUNOoH6wrlCQXZOb7+Vc0JN5NpLGFMzrYaoXt /cV58xFl+eTcjSIfuyUtpccyyVjN0+CEicePizSvfskVuoPKGI77d+1iY371bNj8iebp imHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YsxlfECd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e6-20020a17090a4a0600b0027901ee93fbsi11480299pjh.156.2023.10.09.11.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:41:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YsxlfECd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6D15980BB211; Mon, 9 Oct 2023 11:41:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378172AbjJISlK (ORCPT + 99 others); Mon, 9 Oct 2023 14:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377218AbjJISkf (ORCPT ); Mon, 9 Oct 2023 14:40:35 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1AB110D3 for ; Mon, 9 Oct 2023 11:40:11 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d866d13c637so6318310276.3 for ; Mon, 09 Oct 2023 11:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876811; x=1697481611; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=wfL4FLU++s9CKjil59t6XdpqiER2jatUC+zl7nbhx6Q=; b=YsxlfECdt177X4UMflQL0j0/eiiJ163V49F/TKWFkTlFW+aY45ZLUbU8f6NDVQQigD BtRPIKXxexi76R+oVTm1GCgmpGzx9NSFdWZVepRouWnYHynBJuF78cTALiIizRVnr+Ug 7DFkxBdCvyLYUU6dzWqKmIrjj1k+Bj7M8v5yM7GLYQWHwV6LBCjZEKYGsV6hdXaTETYY 73ANscnYgCjASWj7H2Mpu5TlecYA/5dlHkVSVO57N1VHBI2ObMLd0xYloJy6U6+Dv642 Dg3ao67NHSRXvIcx6F+FW5mpUs9l6giCn1/D4ppTJh+jBkCv8ZEb5aaEJYWUejPZuVk0 o5yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876811; x=1697481611; 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=wfL4FLU++s9CKjil59t6XdpqiER2jatUC+zl7nbhx6Q=; b=Yw2gBu65pvV5azTaDKL3vLoHeMFBzWA8Bnc1ly6LvJyQxc1DQLvWd1mtkHR6QX18+B qg9g9Jfm1Zqz/8lt0GKwToW6V3cNWJvcdM/ffr6lKRQQQs7RDf9P7gsk3GVlHlOo0CGo nt5GcUmGmiL1D4reYXz1/3b0Ns9Xq9YeQS11z8WuvRN2Kodf+lauU887lnTJgtzTV9fn o+pGqH9hPKTySR8FqhcQwEyfVfJ403ZX27yPtvjXEvviN+KgyCHE4Xr3swHbs/B2yMPH BlVirmIujq7KhsL/qm0Ps3E9zpP9EtfB/a7GI32T+EopMavrqE1rgDJF2boNkwy0j6q/ /FPw== X-Gm-Message-State: AOJu0YwKGr5uk5ZUaC2z+F3pJxA6VJMlU6ifOYxgSBowIqUFTAvcnS9G +ViYRD1ieUUaSgBrwYQbDG4Aj1DjMLv5 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a25:e74f:0:b0:d9a:43eb:4391 with SMTP id e76-20020a25e74f000000b00d9a43eb4391mr17704ybh.9.1696876810948; Mon, 09 Oct 2023 11:40:10 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:20 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-20-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 18/18] perf bpf_counter: Fix a few memory leaks From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:41:34 -0700 (PDT) Memory leaks were detected by clang-tidy. Signed-off-by: Ian Rogers --- tools/perf/util/bpf_counter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c index 6732cbbcf9b3..7f9b0e46e008 100644 --- a/tools/perf/util/bpf_counter.c +++ b/tools/perf/util/bpf_counter.c @@ -104,7 +104,7 @@ static int bpf_program_profiler_load_one(struct evsel *evsel, u32 prog_id) struct bpf_prog_profiler_bpf *skel; struct bpf_counter *counter; struct bpf_program *prog; - char *prog_name; + char *prog_name = NULL; int prog_fd; int err; @@ -155,10 +155,12 @@ static int bpf_program_profiler_load_one(struct evsel *evsel, u32 prog_id) assert(skel != NULL); counter->skel = skel; list_add(&counter->list, &evsel->bpf_counter_list); + free(prog_name); close(prog_fd); return 0; err_out: bpf_prog_profiler_bpf__destroy(skel); + free(prog_name); free(counter); close(prog_fd); return -1; @@ -180,6 +182,7 @@ static int bpf_program_profiler__load(struct evsel *evsel, struct target *target (*p != '\0' && *p != ',')) { pr_err("Failed to parse bpf prog ids %s\n", target->bpf_str); + free(bpf_str_); return -1; } -- 2.42.0.609.gbb76f46606-goog