Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1101213pxj; Fri, 4 Jun 2021 06:10:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWq/beZ3/MaDSvoh0wTi6ObwUtcugRqi1FHmaH6oXDnY2I7w64xTFQWLf1ri0zuqNHdITu X-Received: by 2002:a05:6402:40d6:: with SMTP id z22mr4605008edb.125.1622812254598; Fri, 04 Jun 2021 06:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622812254; cv=none; d=google.com; s=arc-20160816; b=kNajLPRjSfJgkOzHZXA4n7YC01Lpk+Ysf8xx8kaI62O8nAZwSznqp8Y8fRxav4rcEV +sEI72d516nG8QNCncMLATDbMEPtYvhq+zJ0Nfxx3ZB5t5yEH9i5ommBJG1kdvsa0fgd MvTb6KmR8xVyozNQ5ekBmrSkqfKjv13xok6SHX+NzUs5IkIK9pemw8NtH6R9Bnfc7wSF DiQPAOGcyzFJxEtsSMK40jcYI3HasXwiYfPUk/SjLGDAW7isZiB5lsb4IwhCLnV8Bg8T i6fX0QbGL9hB9auFkrtILTj3kCznVp1zK61DIx/sVGIaIlFuB9Fo0a0GCDvhfeMQv4BS gK8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GBd65QMlIGee99r2LSDFMsmMzGoJgR1GuodnClUaNB8=; b=I4q+Z6XMqK77Moy1I4+1NAXCjznD7EmYgwPoJqniXTblA/baA+Sj014RaWt5EeFG+s 1IIEgtmvANHJBcOZplljQsjGKzUaj1500GnS/giSlskqKBfMr4TuO1EqTmEPYlGYzzWg /6eHT9IwUN9Xo146m+fiTomknLZKJ+bNNEh3L7XmkG2Zk2LXyJOhU6ES+iqpfE2hIREx Vjv5aaTqjKxzBWmzoSJIWtoBXjbfhj45jTkxe6UiTe6og25b0KjmNkB+QPt0pPYlz63V qObotZpC33DBXPdKwvL7oqh6Fn+/nGXWViK59mVbSqo2noIPf9Db7QGIbrEKnR5dr5bc t6vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OoAsBZNF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si5497442ejb.573.2021.06.04.06.10.30; Fri, 04 Jun 2021 06:10:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OoAsBZNF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231157AbhFDNKv (ORCPT + 99 others); Fri, 4 Jun 2021 09:10:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:47730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbhFDNKu (ORCPT ); Fri, 4 Jun 2021 09:10:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F1C0161242; Fri, 4 Jun 2021 13:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622812144; bh=KHO+U0aZOMLH2SG9CS45ops/zg0OYk/Q1F2Jdo4MHDs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OoAsBZNFMBALH8HjHbOqLEVqWSkhW363ubgORcFWrczTo1D17qKyVFPUFlMX+BRfE G2U1ePuqGfqDS0DAktsvLrCWMqGsumbw5DHWN82OaUSyI1GYzliQyVed49QQoEwqq4 qWsaiIVd1fE9w7a1XZMOO7zjlArX1xvB9YKjH9mPUDlqvnZzCT4Yu5g49JlUELkD/B qGSAKYO72+ypnbhepuhBMD1G4pYY8tdlCwVWECDEqs9FzEq+SEc7FpHjYlLnQ7mbXd 10GXeQmyqREwFI7OjooZ0fHpK7feEbNp47PG2HWJCkyQOmS1hRsgDB2X+JJdx+AIBB RsnSG8uVErupg== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 5E10940EFC; Fri, 4 Jun 2021 10:09:01 -0300 (-03) Date: Fri, 4 Jun 2021 10:09:01 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Riccardo Mancini , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-perf-users , LKML , Networking , bpf Subject: Re: [PATCH] perf env: fix memory leak: free bpf_prog_info_linear Message-ID: References: <20210602224024.300485-1-rickyman7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jun 03, 2021 at 09:15:32PM -0700, Ian Rogers escreveu: > On Wed, Jun 2, 2021 at 3:41 PM Riccardo Mancini wrote: > > > > ASan reported a memory leak caused by info_linear not being > > deallocated. The info_linear was allocated during > > perf_event__synthesize_one_bpf_prog. > > This patch adds the corresponding free() when bpf_prog_info_node > > is freed in perf_env__purge_bpf. > > > > $ sudo ./perf record -- sleep 5 > > [ perf record: Woken up 1 times to write data ] > > [ perf record: Captured and wrote 0.025 MB perf.data (8 samples) ] > > > > ================================================================= > > ==297735==ERROR: LeakSanitizer: detected memory leaks > > > > Direct leak of 7688 byte(s) in 19 object(s) allocated from: > > #0 0x4f420f in malloc (/home/user/linux/tools/perf/perf+0x4f420f) > > #1 0xc06a74 in bpf_program__get_prog_info_linear /home/user/linux/tools/lib/bpf/libbpf.c:11113:16 > > #2 0xb426fe in perf_event__synthesize_one_bpf_prog /home/user/linux/tools/perf/util/bpf-event.c:191:16 > > #3 0xb42008 in perf_event__synthesize_bpf_events /home/user/linux/tools/perf/util/bpf-event.c:410:9 > > #4 0x594596 in record__synthesize /home/user/linux/tools/perf/builtin-record.c:1490:8 > > #5 0x58c9ac in __cmd_record /home/user/linux/tools/perf/builtin-record.c:1798:8 > > #6 0x58990b in cmd_record /home/user/linux/tools/perf/builtin-record.c:2901:8 > > #7 0x7b2a20 in run_builtin /home/user/linux/tools/perf/perf.c:313:11 > > #8 0x7b12ff in handle_internal_command /home/user/linux/tools/perf/perf.c:365:8 > > #9 0x7b2583 in run_argv /home/user/linux/tools/perf/perf.c:409:2 > > #10 0x7b0d79 in main /home/user/linux/tools/perf/perf.c:539:3 > > #11 0x7fa357ef6b74 in __libc_start_main /usr/src/debug/glibc-2.33-8.fc34.x86_64/csu/../csu/libc-start.c:332:16 > > > > Signed-off-by: Riccardo Mancini > > Acked-by: Ian Rogers Thanks, applied. - Arnaldo