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.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 CAAB0C11F68 for ; Fri, 2 Jul 2021 13:58:16 +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 949C96142B for ; Fri, 2 Jul 2021 13:58:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 949C96142B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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=K7qhxt4a86LWc4C1cQrmzHaXS9YmonSgLej2qGslSdA=; b=QLpbI2LPI4QPoB ie9qKyC/6VevaIlwfzggu1zuCubb2EWpflZKtF3xqZ2xHqsv7PQ9trGwqtV9zT8cDWv3vGRpigjnh Gnj8Umgda+GZDiOvJ6rodPtVHPvQqgStjr8EA+ulbNZ9uLFgjKgBEsa92rVOhGaTT/pgNAuhsXIzn 0qcrlihMkux8AlIx1ONQNgf2EmsNDwXVmZ3AobXM4keYPU0/kwq6mxm+9XLCFBEJTEYzKmzIvmy0N IV/YVQilOpvtFgJQWUAWS+mqJDeyeosaG69Vo8w/+SLAAXdngttzl4a0GAXosfTi6q+56W/9+O3r0 oYPUbvQcxSIiBhEGMfkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzJf4-003De7-Sz; Fri, 02 Jul 2021 13:56:55 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzJf1-003Dct-BR for linux-arm-kernel@lists.infradead.org; Fri, 02 Jul 2021 13:56:52 +0000 Received: by mail-pf1-x434.google.com with SMTP id y4so8985248pfi.9 for ; Fri, 02 Jul 2021 06:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=prR9MMxJFXYg7tQTmUSy0zU77pkSRzPHwNGdQsurfnw=; b=jJGc9dbBI79E5l/z1HwBg5pD9bdMDr690Yr/8fEtdU0rp8GXs4gIwfR8JOGiOCFAxY zBCJFA0o7fUuLPLu6aHlt2mLAURxadrVpyKySr7JB39yCT74INAJTuBJBrC9SnW+hmaC 7NbGZGuXwIb3F8BKVzAmlw0W1E0NmHtBIwAaa4+meTVZRDJM1ZS1Idjp3/teipQ7K3wC AKkN1cD6EVwQv/If/iEw4CFjpeNJAKrrqTU8vaWmlGOJ9gQcDAv7mg+wjp77jenrV07N KVKhMiYi8e1gCceb6H3zYtN2pScQ2g7y8d92ub6JRXyi1WhVpGuWQB4mWUKfey2AobjT 85Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=prR9MMxJFXYg7tQTmUSy0zU77pkSRzPHwNGdQsurfnw=; b=jkVCaEBapa6cas/Za42kWwjGEYi5zcJDnExvJO9LZoBZaC+tq225Wb5iB+3yGzHJ22 r1jvQzU0xpzUF9fAWjxtwdvj2ruxjA4OrdIfOy/EA3QmEj58lR0cFX80XsblaUO+F19A 4JEmu0bYNIgnekWQf15JMrIGkA+r4lmYD/LyX8uD/q71M7dbSaYylKB/J3Q0u2fJjJ85 ErhkblYgcnYVKaC3l1vyrfiBlKD+9LN7GUTAJdXEdaoG+XUqZElCgFOsth+ZnjoHXWTj DAYRQXg6szQqfYewsemUgXU2+ptjft/i9dHlM1M2VIqrPJzfgSxQK6YMiRuVzogh/goZ i4yA== X-Gm-Message-State: AOAM531TdRI7fNPn02+jD6KJ2C3auMWKjBJ3aZvkuHft8IPrGn9v5JLG vAA0ZEWo5wYWPoqZ8g489AwbIw== X-Google-Smtp-Source: ABdhPJxfsV4JttWkQ7T3rEm/HugUDpjN+Gb23ibpjWkUF7ReB/JxrJk4ZFHrkD5tF+MTf8AKfxjCEQ== X-Received: by 2002:a65:6412:: with SMTP id a18mr115669pgv.445.1625234208439; Fri, 02 Jul 2021 06:56:48 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([103.207.71.35]) by smtp.gmail.com with ESMTPSA id g2sm3217396pjd.55.2021.07.02.06.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 06:56:47 -0700 (PDT) Date: Fri, 2 Jul 2021 21:56:41 +0800 From: Leo Yan To: Arnaldo Carvalho de Melo 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: <20210702135641.GA22592@leoy-ThinkPad-X240s> References: <20210702040955.631618-1-gushengxian507419@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210702_065651_499373_389F7752 X-CRM114-Status: GOOD ( 13.87 ) 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 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. Thanks, Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel