From mboxrd@z Thu Jan 1 00:00:00 1970 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 17DCAC7EE37 for ; Fri, 9 Jun 2023 00:31:23 +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=bNsgQKQxXebU20Iqprl1yReDuf7rdDKOrw+ze6MfTJY=; b=ircN9RF6KYi0pr lXlFVvmm3/aRjc3OsDF5CDSZRAvZZQ3smns7XUp6qvAe+JBI6kkC4L4fO+MQxPYMCyI2PEofAiM2Q ida2xIkGeuUzTzXLPRzqmwczDpovuzBayAULed/gPGVkSqw8XjpUt6VTs6udyb9LXQHWog9rH35r8 s3ucgKKJPBRiMsYu63f3Za+JgAjomdLiQV3ZqIhq/iGxPuAzHifcPHC4sMgeoY6W22oqsDF7SohcW mM4f7rtFefIi/1NK277fFRtcyHKgswyMdqevnL8yMgMiORCKtCZKPWuH3av+ehhndxyOsnTIcaRf7 IEMWYXW9NP2LyoIQ5rTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7Q1r-00B4Fo-12; Fri, 09 Jun 2023 00:30:59 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7P4v-00AvJs-09 for linux-arm-kernel@lists.infradead.org; Thu, 08 Jun 2023 23:30:06 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bac6a453dd5so1656158276.2 for ; Thu, 08 Jun 2023 16:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686267004; x=1688859004; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=/XZkwenxaaHVyn1hVE7P7MuCL0PTGSRSdV23z9MHnOc=; b=75tmqSXX65bSoRA5vlcyAF43ZjhIM0r5BM3xBN28av2EJVL53fBWeBvuFQ0ohIFV41 V3e/SfmjxZDxFllZWY+DfzkPwq5EuwupokhRmWxhsB+cabmeNVtyY+rArxf9IpdCeymO VjRW1RuE/6ehKGlfxe+QEbCmweVU8ffBiyN/2T/IzUjUVf8kKGxl4/CPvzmG6TALsD37 scAps/eFy6y1VLMpZ7G0O1AbiCez+FkMnTroSZQ/C6xlu2nYF28x/1tRUWH0MH+nJmqp 90NcTyaFWyB7rJgedrkuHPCs1hLxw0udDBCYzMnxUVICERgPpbmS7u4kcIaE4MMnEoPU R+sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686267004; x=1688859004; 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=/XZkwenxaaHVyn1hVE7P7MuCL0PTGSRSdV23z9MHnOc=; b=FjXKkT3FeSFWpYOLv1FTrZ8HT+TdZlGWCEylQDM5HgOjpAC1CFXMsBv5mDOLy7g9pS xPmNpaMVMb7q/z+To4ntxaguDyhl64Cj6zZcOlo1HgA/pUzSBtswK+Xx4oDLa0k/V9xs /iKI+yYRW36FCLduE32aL+f/wjAEgn3ZeY1Z3+Jl1HNetloiXQpwqkpA8RckM6w/QJDd 2hS9DYSdzs6O+Ks0/hKlzYAPZc2yGG1e98G3Xg06JM2koY4SZLdjt3/GS2w7O5dia34D jqIPKSJezmbYs4QMPNZQR+TCsfYrxne+fJpYcksUka+MHvpYaPyfWjjo8Bax5Y7utrRH jsTg== X-Gm-Message-State: AC+VfDxlDJ4k+nbTnsixMRWnHdTffWN4p1IpX6UBvQLlABafIszt1owD iNDTZNrqe3zmprmHEnRJRXdZXL1c+ydN X-Google-Smtp-Source: ACHHUZ4p6MK7UPxQ9Y6RWB+kMCGrMnATf9tWGxq4NXy8eTZomZQ5exYqGqOKFmxU9NXUDopUSDfZylb4u6F2 X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:c3e5:ebc6:61e5:c73f]) (user=irogers job=sendgmr) by 2002:a5b:784:0:b0:bad:99d:f087 with SMTP id b4-20020a5b0784000000b00bad099df087mr609214ybq.6.1686267003834; Thu, 08 Jun 2023 16:30:03 -0700 (PDT) Date: Thu, 8 Jun 2023 16:28:18 -0700 In-Reply-To: <20230608232823.4027869-1-irogers@google.com> Message-Id: <20230608232823.4027869-22-irogers@google.com> Mime-Version: 1.0 References: <20230608232823.4027869-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Subject: [PATCH v2 21/26] perf annotate: Fix parse_objdump_line memory leak 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 , Suzuki K Poulose , "Naveen N. Rao" , Kan Liang , German Gomez , Ali Saidi , Jing Zhang , Athira Rajeev , Miguel Ojeda , ye xingchen , Liam Howlett , Dmitrii Dolgov <9erthalion6@gmail.com>, Yang Jihong , K Prateek Nayak , Changbin Du , Ravi Bangoria , Sean Christopherson , Andi Kleen , "Steinar H. Gunderson" , Yuan Can , Brian Robbins , liuwenyu , Ivan Babrou , Fangrui Song , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, coresight@lists.linaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230608_163005_115168_25944FB9 X-CRM114-Status: GOOD ( 14.15 ) 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 fileloc is used to hold a previous line, before overwriting it ensure the previous contents is freed. Free the storage once done in symbol__disassemble. Signed-off-by: Ian Rogers --- tools/perf/util/annotate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index b708bbc49c9e..fc5f44535ebe 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1524,6 +1524,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, /* /filename:linenr ? Save line number and ignore. */ if (regexec(&file_lineno, parsed_line, 2, match, 0) == 0) { *line_nr = atoi(parsed_line + match[1].rm_so); + free(*fileloc); *fileloc = strdup(parsed_line); return 0; } @@ -1572,7 +1573,6 @@ static int symbol__parse_objdump_line(struct symbol *sym, } annotation_line__add(&dl->al, ¬es->src->source); - return 0; } @@ -2114,6 +2114,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args) nline++; } free(line); + free(fileloc); err = finish_command(&objdump_process); if (err) -- 2.41.0.162.gfafddb0af9-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel