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 X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E304EC11F68 for ; Fri, 2 Jul 2021 17:59:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A318461220 for ; Fri, 2 Jul 2021 17:59:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A318461220 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PgWHF15qHer7Wf7Ih/ihMvrwVvIz2mLwOxvjxK0AENA=; b=jhSmoHSl22jS0/ R78JLGftJCKDdI+LgeYkaUFq2sFmY03mX6y1mj0lJ6CfI7gmApenfBa5R6WpL71FLLRTXY902mLYL /il6zZ1mqEJ9YEuCe5rg3HUOuN+5c2OJn7ozx0PZjZPejuTixsAcGVbqQ4OUd4Zht0R+dwemuXmKt r3iCC8DbsBG5Euw7sqdyrZit4RcSkYnbQwpLWeSWUahJZGbNycDwD1pSge+JKdAntup72Szv2Dl2q hr529XuKCsMS/ulN2z9F72KNdHFQ0Z3FEdGYeb1FzJ82YkHXzC2VFHYqJ0tE71YRHP/U1HV5G49LG H7kw1iniSAZH4GloQPwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNQN-003hQJ-Kc; Fri, 02 Jul 2021 17:57:59 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNQL-003hQ0-Ko for linux-arm-kernel@bombadil.infradead.org; Fri, 02 Jul 2021 17:57:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bH2VLPwn2Tw5Fci26CA9klqoW7GKiCH8eNpPSLhYbj8=; b=ecSE4VqBSKJmsFECW5e8nFG4UQ Rp8xeiHM5CisnoIK50UjDGqOAGMNiVa34e04jcnhbwkl6tXsddGaRZ0V8qLUSsc8R6t5t+GbDD1+4 44jPRg12kPf291Uvo1uJRwlk0EReY24m/D4MGz8IREMXDQaYjrkmT0GjTokoFQkT1h49/OfDLyHGc NLiHQPgGED10BbsF1ZiHTqXPyuY9yCrNhMq1odz03uyvHJZoz2Vi9CX/Pehz4e8vXreTmgKMyS9E6 ZT2ncQZO4XwXT624fvs7kWrttomFoyvPc4ld24kqotBRo8D8MeI9D3vsqKEv+mbi6FpFKs6SsM23X xXSvaxWA==; Received: from [179.97.37.151] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNQJ-00Dupt-SS; Fri, 02 Jul 2021 17:57:56 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 89C8E40B1A; Fri, 2 Jul 2021 14:57:51 -0300 (-03) Date: Fri, 2 Jul 2021 14:57:51 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: gushengxian , will@kernel.org, mathieu.poirier@linaro.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, gushengxian Subject: Re: [PATCH] perf: tests: fix some mmemory leak issues Message-ID: References: <20210702040955.631618-1-gushengxian507419@gmail.com> <20210702135641.GA22592@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210702135641.GA22592@leoy-ThinkPad-X240s> X-Url: http://acmel.wordpress.com 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 Em Fri, Jul 02, 2021 at 09:56:41PM +0800, Leo Yan escreveu: > Hi Arnaldo, > > On Fri, Jul 02, 2021 at 09:58:52AM -0300, Arnaldo Carvalho de Melo wrote: > > Em Thu, Jul 01, 2021 at 09:09:55PM -0700, gushengxian escreveu: > > > From: gushengxian > > > > > > Some memory leak issues should be fixed by free(). > > > Reported by cppcheck. > > I don't think this patch does the right thing. You could see that the > memory is allocated in arch specific function sample_ustack(), and the > "buf" pointer is assigned to sample->user_stack.data; and the memory > actually is released in the caller function test_dwarf_unwind__thread: > > noinline int test_dwarf_unwind__thread(struct thread *thread) > { > struct perf_sample sample; > unsigned long cnt = 0; > int err = -1; > > memset(&sample, 0, sizeof(sample)); > > if (test__arch_unwind_sample(&sample, thread)) { > pr_debug("failed to get unwind sample\n"); > goto out; > } > > [...] > > out: > zfree(&sample.user_stack.data); > zfree(&sample.user_regs.regs); > return err; > } > > So this patch will break the testing and doesn't fix any memory leak > issue. You are right, those buffers are allocated in those functions and then _returned_ via sample->user_stack, the tool (and myself, ugh) got fooled, I'll remove that from my local tree. Thanks Leo! - Arnaldo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel