Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2076824rdb; Mon, 9 Oct 2023 11:40:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF68gEVd2b3jnWLO8VOlEEHGMIHuTnz5H3IdGE6lsAVeSYgLeysyewdDNuVPc/1tLe1E5wL X-Received: by 2002:a17:90b:4acf:b0:268:b7a2:62e8 with SMTP id mh15-20020a17090b4acf00b00268b7a262e8mr15230258pjb.7.1696876838562; Mon, 09 Oct 2023 11:40:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876838; cv=none; d=google.com; s=arc-20160816; b=0soDnc55qe2SaAS9ASi7U0xmjXV4FXbnWxDBPBjnV53LW1byEBkJLFWhU3TykNvL4d SjXB0VFWigwSF2PIUE6kUw1/H/cnX1EXJkr8cZ0sZrZwks76+VBr8VgDp3OYI++eAGix iWhrs3qSI3mXCN3QO+U/PWnS1rYagUmIDyD7qpyiOsQFNnxHtnnEfA++XA2fmOofZ98C GZWo6N1tF/EDYNV6FB7ZdaWjPqHTZg4RFIV+7dgx1Lh+8nQm2tCNbsJQ1lxqnI1Q8Mtn feLIvGsfAubsPfXJO4Ivs4VOgBPd9eZAwwq8szbIcD0VdhJazINU8g3WeaiM/jGg3nkd /g6A== 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=GouG30KZVQtjqm6aov/swqA2g+y6OD5o5DKI6J9/hJA=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=09oRy0a/hBNb5CKTTkxbJZSGaFx8r9u9dh2SAYhXSYwTWpjFHXuEiZc0N7Gbiixerq ICH2YF4IzHCXwJe6mYtoG+y8kaNIv+VdBqzGq18iGaSznSdnhd7F8HSNy/URo00gNMpU LBad5WpEOjbAr+cZCiKpvtUfVjVi84PSFnBEC0hIgLNJmfjLSATCWZPUZDfc9XJiNRwC OFEwYmckoZ3/HXkC55+2qLKv5eyA6o9YPlQr+Yr2MFoa9yEJm+6hgZgkchb1/d3AM2Ad CBa4gfxLxxAuss/tqN7732d19ZVTgxHZmMszveZzrOhzjEbv0YNdL+0TaqX1qkr/yDDr 4oYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hdiUtupS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id k6-20020a17090ac50600b002774e11ca41si12088682pjt.67.2023.10.09.11.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:40:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=hdiUtupS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id AC7AF81CA3E8; Mon, 9 Oct 2023 11:40:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378359AbjJISkC (ORCPT + 99 others); Mon, 9 Oct 2023 14:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378287AbjJISjv (ORCPT ); Mon, 9 Oct 2023 14:39:51 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB8E5128 for ; Mon, 9 Oct 2023 11:39:45 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5a23fed55d7so77427437b3.2 for ; Mon, 09 Oct 2023 11:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876784; x=1697481584; 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=GouG30KZVQtjqm6aov/swqA2g+y6OD5o5DKI6J9/hJA=; b=hdiUtupSykpW0XElbBBe/4kSZCj8u8m+VgHsIC9uBIpw2OeCQntgd2Or4zBdEbuTgf o8Fl8dvqTdKCPzb9QQ96OYyO2jocXYnCk7YsfGy8OWlPlSvLYmUYK7xngvymGis72dz6 6LRwWnfhjVkVcmisRxN8zyXC2n1o0GxOilWeOHGjM3s8STxdCs7zVv0B0q7vfWrX66Pd BRPIVRof0u2JM8YFLWlrPnXtKmI+k0r1Boai3dUA/VLl7sqiApH+sYQYeqTYFBH98LUy QSVrUuknZsdVaXQr1MgaowmkngG6z61yOUBTPU4j9wB9/3mw6Zg7DTl5AGhsgYFlyOEx Pdjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876784; x=1697481584; 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=GouG30KZVQtjqm6aov/swqA2g+y6OD5o5DKI6J9/hJA=; b=XbBdDWZinalTdZvIzx+KmqGTYuwhesYxrNDYmxLLqqNblOpxZ/njFvzDOBUqrtYV+L HsvcZPTAim2YjC+H6HYxb6Kn3E88woT/VWMueWzYieuv3PmLT91pNB9y3Erz0AYnKAvf RGP0BmD3rdRHdA2dPxux1IEZg3puybgpDQWTMhB8HdJQtdY02ojpEXzl0GRjP6/kQ61R G3fljxw74/fzxboPV610ke2/zvVvNz/aoOmklNVM5XpNb2+mv94eFVtASrHBJDrl0F2q iOQArFuB/c4AO7STFiDki2Hw7kPnead+ix7rn92XHZ4lF3Nm8iNDNIRdc3xB+YUpZDZS yHKw== X-Gm-Message-State: AOJu0YyqkUffi0Lpjoqel2nDLwmi7jmVtnjgpAYMkmx1nG2dvCcTTxMi B6S9tXecyZu9w9jTGC9JyE68onBExV/h X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a25:d12:0:b0:d9a:3bee:255c with SMTP id 18-20020a250d12000000b00d9a3bee255cmr25038ybn.7.1696876784641; Mon, 09 Oct 2023 11:39:44 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:09 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-9-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 07/18] perf jitdump: Avoid memory leak 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:40:31 -0700 (PDT) jit_repipe_unwinding_info is called in a loop by jit_process_dump, avoid leaking unwinding_data by free-ing before overwriting. Error detected by clang-tidy. Signed-off-by: Ian Rogers --- tools/perf/util/jitdump.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 6b2b96c16ccd..1f657ef8975f 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -675,6 +675,7 @@ jit_repipe_unwinding_info(struct jit_buf_desc *jd, union jr_entry *jr) jd->eh_frame_hdr_size = jr->unwinding.eh_frame_hdr_size; jd->unwinding_size = jr->unwinding.unwinding_size; jd->unwinding_mapped_size = jr->unwinding.mapped_size; + free(jd->unwinding_data); jd->unwinding_data = unwinding_data; return 0; -- 2.42.0.609.gbb76f46606-goog