Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3940711pxj; Mon, 24 May 2021 19:20:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXo0TCQ0mMquJYUXNV5FazSBAJWHZi31cLpKOSzi6AZDsLf0NAkdxMwyb0XSCDrM58pzHs X-Received: by 2002:a17:907:2071:: with SMTP id qp17mr26201808ejb.15.1621909253681; Mon, 24 May 2021 19:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621909253; cv=none; d=google.com; s=arc-20160816; b=M0XQo1gVTo2EKcfk0EG14OVMRih0G8h8ZgB64g28Tb1RsOKevfRd4QdHzgJbzDkJRP oEqcMuxKNLTYH0b89pWOwGa84Eb4lR74j6egAWwOSsYsRMSCQ4u+7SPe3d2684Dvz6t5 I7EH9VGZRiYlRV20b7fnD8QAV8fibqoslh0aWU0PXAkYw+89VD1sbQ7DfToJ7BCp5Mdl D0uWHWeTP3qEHo7qDUJCJgchp0nbP76H+gb9Mdp685kg4uVSAO5S7pXpNcN1usyO9jVb yLr2lDfOJUACU830jaGsMAGxZ4UWn5mmLoNZHNwPb4juFhl2GrqdmTvgZFtHlanoiP2N SfAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=wte1SKA2OPTSfoBJkEtuKRHiWvRqmL9Uhhmysnir8xQ=; b=x9ClXAi2nX3ruVDb8PeDpoqXoduZhxde725sdXs5orNDTZ6uPzgiBjI09Ki0dwT0aX qKyLWDWBDZVw5CcrNwFcODx8TdWk6Lihn8oHTP9yXEOYBf9okl1Zpd4RsoeQhrcfFGOI oRBLIhARAWXqueCekX54jK6WR+R59F/zfLgWqW6trFUoroDs5CznxV53Kw6pmBAcUxhK JvIIAAswExi89A9uhmyQtuXVjxAmtX7298ejsB5L/B+odT3wlLyu9nT2nLUyfpv1uc3T WTTq8bJ+uHnP2H/Q3ecsjECpg9NWUzwoEzbAxVGb0507QGkLu+awmWr89mu0pD+q96JJ FgMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bh7si12406254ejb.383.2021.05.24.19.20.24; Mon, 24 May 2021 19:20:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbhEYCSS (ORCPT + 99 others); Mon, 24 May 2021 22:18:18 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5766 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbhEYCSR (ORCPT ); Mon, 24 May 2021 22:18:17 -0400 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FpyKg6yGWzlY9D for ; Tue, 25 May 2021 10:13:11 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 10:16:46 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 10:16:45 +0800 Subject: Re: [PATCH 03/12] zap_sector: fix memory leak To: =?UTF-8?B?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+INCQ0YDRgtGR0Lw=?= CC: , , References: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> <8ea5c607-54cc-ccaf-3e4b-ee2af0160a0b@huawei.com> From: Wu Guanghao Message-ID: <1fe6c10b-9bc0-ebd6-e69f-8ad69797e780@huawei.com> Date: Tue, 25 May 2021 10:16:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Thank you for your comments, I will modify it in the v2 version. Best regards Wu Guanghao ?? 2021/5/24 22:40, ???ݧѧԧ??էѧ??֧ߧܧ? ???????ק? д??: > Hello Wu, > > Thank you for the fixes. > > It looks like free and return operators should be placed in {} block. > > { > free(buf); > return; > } > > Now function returns any time block is read successfully. > > Also, this patch can not be applied cleanly to the master HEAD because of wrong offsets. Please rebase. > > Best regards, > Artem Blagodarenko. > >> On 24 May 2021, at 14:20, Wu Guanghao wrote: >> >> In zap_sector(), need free buf before return, >> otherwise it will cause memory leak. >> >> Signed-off-by: Wu Guanghao >> Signed-off-by: Zhiqiang Liu >> Reviewed-by: Wu Bo >> --- >> misc/mke2fs.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/misc/mke2fs.c b/misc/mke2fs.c >> index afbcf486..94f81da9 100644 >> --- a/misc/mke2fs.c >> +++ b/misc/mke2fs.c >> @@ -586,6 +586,7 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect) >> magic = (unsigned int *) (buf + BSD_LABEL_OFFSET); >> if ((*magic == BSD_DISKMAGIC) || >> (*magic == BSD_MAGICDISK)) >> + free(buf); >> return; >> } >> } >> -- > > . >