Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3673855ybc; Mon, 25 Nov 2019 19:03:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxa8sUK1kRcBzEwZD1Ykm7Yq+dzA1zX5FWmyaDQAEA9N0ymMg+O2K2SKa+ZHW73wtbm0qPz X-Received: by 2002:aa7:c990:: with SMTP id c16mr22843311edt.91.1574737388341; Mon, 25 Nov 2019 19:03:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574737388; cv=none; d=google.com; s=arc-20160816; b=yKYOK847n0SU+TbThdVq0tCmcq5NfYfuUUzynNNbaEJktFOWRIKiZWdgzC/SXUpfUq UDQp74Z2J6wMqZF9/jsZHakn2ukTYJowIf4PkMl6qNrPZc1NL+RrXQwiMY/B52/NgSiI ORSplNEicSmwj4LZ9vQyd+EkMG/MTUfoTOmgfcbFWR7z1PCFVwqybF9n77bvdE4/1Uf8 gJuXtImrVStJPjm51LxHCreiPFn9Y3CYkERi9lrUqWvcsWKU3TpAVDeC2scf9Q6HwBSs mwCQ6AGTFrEdM1ZUQz8rpAT3vcXgBjD4dj6UemcXzZOC3bE7q73Nfco45r7nzUvAspwV o0DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=3zfISRKo5Nh3dbT5YOGmgY8felC+OiCOU9TkC+utFWg=; b=Ofmhk9TWn9iXYYJuqgjp3ngkmx4X9SI8+O/CZiQYBceC8+e0su8TId/vq7sID2dOuu iEJ3gZyNRduesTQO8+om6GtWG5bzmB2iWvrYaIvJ0CL6Vkp79DOHc8aKOfk57za8d4mn AwILD9oDmy6Zw9BIv2yHuiMSNMD7DzzRgVrvDK8TeTcxf4/gswuk60SZuG/z7KIWPh5i Is+BWz0k3CbpcwGK2lZSRkeLyLxT85xoscL+n4FwyTm2HtwCOlSD+l1dub3ZfhZiz/zm kzi9v/Jw84dRP9jsXTbf4L3m1JF6qHdzQUGdR0bRTywsoalwTHNEbpAGKozHKHU+5Tx4 kI8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si5670923ejj.70.2019.11.25.19.02.40; Mon, 25 Nov 2019 19:03:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbfKZDAw (ORCPT + 99 others); Mon, 25 Nov 2019 22:00:52 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:6710 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725946AbfKZDAw (ORCPT ); Mon, 25 Nov 2019 22:00:52 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A7212AE2EC6CABDAF300; Tue, 26 Nov 2019 11:00:49 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Tue, 26 Nov 2019 11:00:40 +0800 Subject: Re: [PATCH] perf c2c: Fix memory leak in c2c_he_zalloc() To: Jiri Olsa CC: , , , , , , , "hushiyuan@huawei.com" , "linfeilong@huawei.com" , References: <9d5f26f8-9429-bcb6-d491-cb789f761ea2@huawei.com> <20191025120154.GA25352@krava> From: Yunfeng Ye Message-ID: <1847ad5d-05b6-5680-f08d-bdd8fbf54da3@huawei.com> Date: Tue, 26 Nov 2019 11:00:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20191025120154.GA25352@krava> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/10/25 20:01, Jiri Olsa wrote: > On Fri, Oct 25, 2019 at 05:42:47PM +0800, Yunfeng Ye wrote: >> A memory leak in c2c_he_zalloc() is found by visual inspection. >> >> Fix this by adding memory free on the error paths in c2c_he_zalloc(). >> >> Fixes: 7f834c2e84bb ("perf c2c report: Display node for cacheline address") >> Fixes: 1e181b92a2da ("perf c2c report: Add 'node' sort key") >> Signed-off-by: Yunfeng Ye > > Acked-by: Jiri Olsa > Is this patch applied? thanks > thanks, > jirka > >> --- >> tools/perf/builtin-c2c.c | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) >> >> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c >> index e69f44941aad..ad7d38a9dcbe 100644 >> --- a/tools/perf/builtin-c2c.c >> +++ b/tools/perf/builtin-c2c.c >> @@ -138,21 +138,29 @@ static void *c2c_he_zalloc(size_t size) >> >> c2c_he->cpuset = bitmap_alloc(c2c.cpus_cnt); >> if (!c2c_he->cpuset) >> - return NULL; >> + goto free_c2c_he; >> >> c2c_he->nodeset = bitmap_alloc(c2c.nodes_cnt); >> if (!c2c_he->nodeset) >> - return NULL; >> + goto free_cpuset; >> >> c2c_he->node_stats = zalloc(c2c.nodes_cnt * sizeof(*c2c_he->node_stats)); >> if (!c2c_he->node_stats) >> - return NULL; >> + goto free_nodeset; >> >> init_stats(&c2c_he->cstats.lcl_hitm); >> init_stats(&c2c_he->cstats.rmt_hitm); >> init_stats(&c2c_he->cstats.load); >> >> return &c2c_he->he; >> + >> +free_nodeset: >> + free(c2c_he->nodeset); >> +free_cpuset: >> + free(c2c_he->cpuset); >> +free_c2c_he: >> + free(c2c_he); >> + return NULL; >> } >> >> static void c2c_he_free(void *he) >> -- >> 2.7.4 >> > > > . >