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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42613C7EE2F for ; Mon, 12 Jun 2023 17:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235876AbjFLRXw (ORCPT ); Mon, 12 Jun 2023 13:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbjFLRXq (ORCPT ); Mon, 12 Jun 2023 13:23:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC828B2; Mon, 12 Jun 2023 10:23:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 721F862905; Mon, 12 Jun 2023 17:23:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F868C433A1; Mon, 12 Jun 2023 17:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686590624; bh=num+HBDgMxiuiJVhhkLVPXPpTBWWc1dgJNLDNOGS0Fk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uE12zDMfqRoci4thscAdp3EhSwgKJovJnYvOw3krcV88NGXiZRfF9rOltrCAswAXN TfhY5m2ULY71VP3EtGag4nbFEWKPxzFyMuPG3QaaBg/FgP+axXyraqmxKkRVEr1jrU F66fBJdtR7u5XF+bUxf0nc+uNB6UiSdxpS8WPdPSdUngO54Nwdyul+O0NltvPBgBM8 TvC8+1fybwIMNUxG4m6semSiG+yDfRzznvXhkjSxhCVJnuQm8vMTm8aA0J1tYNM/j8 U+YEG8QI3Byfa1wCkMeiCHNt8OmLMklpSKeGCgZAzvJPIay/RL6ThyyfZw0zP4XgJK 1ODSUu14Pl9WA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id D1BF540692; Mon, 12 Jun 2023 14:23:41 -0300 (-03) Date: Mon, 12 Jun 2023 14:23:41 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , 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 Subject: Re: [PATCH v2 26/26] perf hist: Fix srcline memory leak Message-ID: References: <20230608232823.4027869-1-irogers@google.com> <20230608232823.4027869-27-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Jun 12, 2023 at 07:46:14AM -0700, Ian Rogers escreveu: > On Mon, Jun 12, 2023 at 7:16 AM Arnaldo Carvalho de Melo > wrote: > > > > Em Mon, Jun 12, 2023 at 11:13:59AM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Thu, Jun 08, 2023 at 04:28:23PM -0700, Ian Rogers escreveu: > > > > srcline isn't freed if it is SRCLINE_UNKNOWN. Avoid strduping in this > > > > case as such strdups are redundant and leak memory. > > > > > > The patch is ok as its what the rest of the code is doing, i.e. strcmp() > > > to check if a srcline is the unknown one, but how about the following > > > patch on top of yours? > > > > [acme@quaco perf-tools-next]$ strings ~/bin/perf | grep '??:0' > > ??:0 > > SRCLINE_UNKNOWN ((char *) "??:0") > > [acme@quaco perf-tools-next]$ > > Agreed, the strcmps make me nervous as they won't distinguish heap > from a global meaning we could end up with things like pointers to > freed memory. The comparison with the global is always going to be > same imo. > > Acked-by: Ian Rogers Thanks, applied and added your Acked-by. - Arnaldo