Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3330788pxj; Mon, 24 May 2021 04:22:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZDOkAlHyfNkRPUBLWhnCpecy4izSin0/tOFx1J9rt4jQs2PVdUuilBd9hlvRXBZrjWFx8 X-Received: by 2002:a05:6402:30b0:: with SMTP id df16mr25076417edb.85.1621855339902; Mon, 24 May 2021 04:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621855339; cv=none; d=google.com; s=arc-20160816; b=OWuw+gLRcDapApNf2wBcHwsqfBRaNevAGT+/pZDUkx0kUTgxAD62rOvB7Gmtc4FoY6 fbu2WVPNk73aRiiSproQKqZ8fhGeO2ky131dAlwsdP1XwUCTS2GWIjOY5KQ80/JLZ9M3 eDRvaeHIk/rImvKAmpmb1PhS3eZA+rkrSRskkNtNBydBblzMPJY0KcQRxkmojsK0Db8A t8R0RtUuRLzKgTcAsOaiPkb5iYysxA92IpxOxuvAXEWVKRe1SzUGsWjna5enJRZGpjpR ZM4vfdnyWrg/FdGLYZLJT+CQwwXQIeFxQ09slK/fHif5QGbCoqjLQvI6CIpv8/WyA5XJ D+tA== 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:references:cc:to:from :subject; bh=THHU8vr+sw2tKa6fbM1dALbxBbQ+TTHWrF2YuxlSxRk=; b=tAam2a2zmHz1YMCA5+PyBwyehegPRwSmbVZXub6QP7Xqx0K0dqOnJ1tgueuPK7ssyo nmj/7z0v69Vmedf1mAYhbvyTV1ttJMa5B/7jG+TNewuXSxAuIwnQnFc9gQaBqf2QF1FE 9x7JidlFqxOcsoSbtRNsSHXAd4+fJjXXxt8+KMv0xfdJyWxxMIBjk8wAuJiWNLuTlRyY qYuqE4buQxfvKsgn+8nmdoqAvsALEuQ5x6FEAI8zIhyzsN2RQf540KzooAO6BThb9rbm dgIoO/avuMZMyOo8t17wbt0ZkuCrJo4dpY7/TiWRBSRkW5ECodge0FD4sIvMJ32yo8Dq d8Sg== 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 t21si12998899edw.597.2021.05.24.04.21.56; Mon, 24 May 2021 04:22:19 -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 S232706AbhEXLW2 (ORCPT + 99 others); Mon, 24 May 2021 07:22:28 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5752 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbhEXLWY (ORCPT ); Mon, 24 May 2021 07:22:24 -0400 Received: from dggems704-chm.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FpZS06t58zmkrl for ; Mon, 24 May 2021 19:17:20 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:20:54 +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; Mon, 24 May 2021 19:20:54 +0800 Subject: [PATCH 03/12] zap_sector: fix memory leak From: Wu Guanghao To: CC: , References: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Message-ID: <8ea5c607-54cc-ccaf-3e4b-ee2af0160a0b@huawei.com> Date: Mon, 24 May 2021 19:20:54 +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: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 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; } } --