Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7485278ybp; Wed, 16 Oct 2019 09:19:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGr2+TBHcbhJx8zy/pJW4xtJmwson2ZBbaEJrFUdBT8wenx1bzNWWoNri6XLWrXiaxKiiF X-Received: by 2002:a05:6402:12ca:: with SMTP id k10mr40131656edx.91.1571242797768; Wed, 16 Oct 2019 09:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571242797; cv=none; d=google.com; s=arc-20160816; b=oV+Si9eg7X493ahlP0JM8W5lysE3OYsiHR4D+uY/q0ox9MJR6LBOFlefsSp8w8zZ6L 7pjrPkg8/SJDkKy/5L+W2N99bO24koDUYWAgsFgZ6d1rdY451nGH6H3PRk6HYuddiOFk hWMwFJ6IZA1DgQkGxrFRxcm6NJdbRuiU0lyT+YBOQvixr4ZQuZaBrYH2PU0TvLdwZUtS iOZKWHdOqAjVrc2VHrEYSxT8WlW/Ty6xIUJvOt/NyGKYcPFNWXku9h+WY5QhDwJg9p3W 2LUcHVSwrFRuLGqI5lRdWfy0zWrxHRbiiGmf3+dAM1c15KbsY3HNuwOVUwxTO+Mpc4Vk a1IA== 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=1g0DSEa05qQ9bn+qhRxLRcnX4hgMm7i34D6hlZTStqs=; b=NZpdFThYbVTSUkvA8SMSgiKqJXfYZ+PIH/4Ef+yO4+eCWbX0VECTV8nTSClibBHcf9 TYdZhSXXVbxmiwdYylIN5Gj1yZLkmc/8HJv1DakYTTGcMFUroGs7BoiQ6iULmsnFo0TG YWPv/KTeASwuK2FWIGA6zRESBbyvOC0XRrI+ZHEWT/wFoX2z8VPPhMdpXZ6KLX0QAwAF bLgl2x+bXKr5G5vPVrBHrx08PhmLBBvDzh2Uw+RggnvzcUNlJOno12Jcj6wtF39+F2vz IXbBFMlrugd0aLKzzja4YXpE69WkKjhozerjrPsevmpU3+dZDkyqpoU89m/N6TDChE0C /RBA== 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 h14si17578394edb.425.2019.10.16.09.19.35; Wed, 16 Oct 2019 09:19:57 -0700 (PDT) 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 S2393937AbfJPOUC (ORCPT + 99 others); Wed, 16 Oct 2019 10:20:02 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4224 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727442AbfJPOUB (ORCPT ); Wed, 16 Oct 2019 10:20:01 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2C655EECCF023BF90BBA; Wed, 16 Oct 2019 22:20:00 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 16 Oct 2019 22:19:54 +0800 Subject: Re: [PATCH v2] perf kmem: Fix memory leak in compact_gfp_flags() To: Arnaldo Carvalho de Melo CC: , , , , , , "linux-kernel@vger.kernel.org" , , References: <7fd48f77-fbc4-b99f-60c1-ccc7d8d287e9@huawei.com> <20191016140651.GF22835@kernel.org> From: Yunfeng Ye Message-ID: Date: Wed, 16 Oct 2019 22:19:51 +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: <20191016140651.GF22835@kernel.org> Content-Type: text/plain; charset="utf-8" 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/16 22:06, Arnaldo Carvalho de Melo wrote: > Em Wed, Oct 16, 2019 at 09:26:50PM +0800, Yunfeng Ye escreveu: >> The memory @orig_flags is allocated by strdup(), it is freed on the >> normal path, but leak to free on the error path. >> >> Fix this by adding free(orig_flags) on the error path. >> >> Fixes: 0e11115644b3 ("perf kmem: Print gfp flags in human readable string") >> Signed-off-by: Yunfeng Ye >> --- >> v1 -> v2: >> - add "Fixes:" message > > No need for that, I did it already, just next time look for when the > problem you fixed was introduced, that way the various bots out there > can pick this up for backports, i.e. your fix has a higher chance of > being beneficial to more systems. > Normally I will add "Fixes:", this time is forgot. thanks. > - Arnaldo > >> tools/perf/builtin-kmem.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c >> index 1e61e353f579..9661671cc26e 100644 >> --- a/tools/perf/builtin-kmem.c >> +++ b/tools/perf/builtin-kmem.c >> @@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags) >> new = realloc(new_flags, len + strlen(cpt) + 2); >> if (new == NULL) { >> free(new_flags); >> + free(orig_flags); >> return NULL; >> } >> >> -- >> 2.7.4.3 >