From patchwork Sat Jul 20 10:33:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongpeng Yang X-Patchwork-Id: 13737790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBA79C3DA59 for ; Sat, 20 Jul 2024 10:34:36 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1sV7QA-0001wL-9K; Sat, 20 Jul 2024 10:34:35 +0000 Received: from [172.30.29.67] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sV7Q8-0001vu-6X for linux-f2fs-devel@lists.sourceforge.net; Sat, 20 Jul 2024 10:34:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=B+CcTzxFnSc0blY69GjJxpN+CCB0nM3YiiWH2jUP8rY=; b=P9xG3uMAbj4uaG7XQ5eGD/kA4g AxKK7+6IsnXhPwGLdt0xARdBG1orKLoO9rKDD80Su8AXBMp2he9/fkxhslMTbRn0XMpvRYzzmQsPI TDtB0b+lBfB5/pn2OVcK1Xu/FiFJ2E6A7D6WZ1SHkphMhkxhfmSmBPeY+x3E//mThy48=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=B+CcTzxFnSc0blY69GjJxpN+CCB0nM3YiiWH2jUP8rY=; b=R MhfrZhhXiZ2fqGg9vKGhhahE4rL2Xn35ipxjRst7SUjWGjuXcwLvLueYBUwMmv6zG5ecF+Y9CSlOd omLA/k9miopObjue4Bud41NPCVHPBAk3dia1fQO4oDlDqQf0I9EZvIadZHDPBQ09kQodzwUzwsd0O WwhtcR8gJHooZy2I=; Received: from mail-sgaapc01on2070.outbound.protection.outlook.com ([40.107.215.70] helo=APC01-SG2-obe.outbound.protection.outlook.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1sV7Q7-0001pr-Bf for linux-f2fs-devel@lists.sourceforge.net; Sat, 20 Jul 2024 10:34:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WfseHttwX6JO+iGqBgOASwTLQHJNGdGKrP4kEc0PnMCkyYkizpS71ZXROsUFEblmdGxMFAhD8r5MhjwHivuZ1x7byqUjYqwT41xk0Btn3zSaNbPbG4is8oQnMt4Iui+5LJuxGAagxLG7wX0dc9h2+c8lNTpLKjVz56g432kiHOe1A+S9v80sXTia3aVJyjHdj+mC98hyBLzSCOkASFnNKdnUTqIvkunmZcJgbCeMQ+y1lrJDh/n4RmK0vDntX8bCzAZphGtBrsvFRnuy+LEbu7UiDBkvfeB97kz3z1AgOdWXUn0L7Sl1gHFR1i4CK3YJ8CcOsxmWp4RmIgFj+dlpRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=B+CcTzxFnSc0blY69GjJxpN+CCB0nM3YiiWH2jUP8rY=; b=T8m0v6c/pB0K4rz4/3Pmh2dKxOBxwq5b4PLNUQOktk4mlku8bLVFJoWGr+p1kdZZt0f2G+CAU9hrMcRcjr1H7NdxXOIjTq3VpOn1TtDA2xYK+qDY3BclVuvcRM+t/pXbFk/XNQlCHJ6U666LGCdDdqEOPRk/J/b5r6LbO5Nk6mrWZ7AfslRW84dyiaOvfCxAs3BqhfKxo0lw95O78BkIyudYdsPKExehx2UzXr60WsstFjZug3qbu3Lz1zW8FueUu78UQ1Denono41It/bgG5jb5TtFNHpFkWqt7HmDMOCNKoaZH1MjxVL3iyGuUPN5zTHcJ543nIdMx0QnmEPAdXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B+CcTzxFnSc0blY69GjJxpN+CCB0nM3YiiWH2jUP8rY=; b=uyJ8AaSTWXp2i/Qg/2yyTIkSPZBtpV3bTrqpCOjC0GUaVBdiGiBEE91PyDJSrNdOfU7jQypvyRZ9pMN9TKq651NaSY/5gqQz5OawEVPnbkAPlrEOyaRj48jMvzrsDl84pPINoZ0GeJuwp2xlps2JRU40hqWVrvQLQgW8KOrNlzQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from PSAPR02MB4727.apcprd02.prod.outlook.com (2603:1096:301:90::7) by SG2PR02MB5652.apcprd02.prod.outlook.com (2603:1096:4:1cc::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.27; Sat, 20 Jul 2024 10:34:19 +0000 Received: from PSAPR02MB4727.apcprd02.prod.outlook.com ([fe80::a138:e48f:965e:36f9]) by PSAPR02MB4727.apcprd02.prod.outlook.com ([fe80::a138:e48f:965e:36f9%7]) with mapi id 15.20.7784.016; Sat, 20 Jul 2024 10:34:19 +0000 To: Jaegeuk Kim , Chao Yu Date: Sat, 20 Jul 2024 18:33:49 +0800 Message-Id: <20240720103349.3347764-1-yangyongpeng1@oppo.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: SG2PR02CA0009.apcprd02.prod.outlook.com (2603:1096:3:17::21) To PSAPR02MB4727.apcprd02.prod.outlook.com (2603:1096:301:90::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PSAPR02MB4727:EE_|SG2PR02MB5652:EE_ X-MS-Office365-Filtering-Correlation-Id: cf4a8f67-c9c4-4431-f734-08dca8a782e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: +i6YL20BFSmKDHX93t+qDaQTN70KFbH5FPpkq+Z6nyh3yB+cF3gcYpRGR8Tq19cfsO4cpORIX/lrpUn49c8zNQEL4Ji8mBvOFxxP8xljQ/fNkFeVFJw4/w/FWX7yfDwGeMsR0j99U1NgAB+++aMOmhRi7yVCMbza64okXVKZAYrpXbFQosZmdhQBoWTXEeGqPTEnXLmbcXSjM3NgOJp3aQLgIXooS2ixIQEbTKfd++8Kwso+GhSduvIlH4gu60YlfxGT98AsU3EHYFvGLN7SkRRjx5q4eaGIWzNvgM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r01kcECDaVLkZokTG51q/BwKpOq6GxC0zFr3ZaaFAmVbpENAg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PSAPR02MB4727.apcprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DeE+D24m2cuf9fto/39C57u5MTnCMmF1zIQb2vXj4w1FFn862jdU/gNNBmWuVwynnF5SKHeIir9NNMPw4X/h8zBazFuzor3wkRb5K5uOjMNaZR/iAe77K/8qvKlsm8Qo2lV4/F7Cz0lFzfBP9ZzBGQRRN9UJ/EGK4uXmfvfhYtQZA5fHLvcvrEfac2HkI0oaxYnVkJOltdIOivj3lzdaziMuEaGqIJKwMB+45EFSKdqk6XW5Ae4PCN5mpmI6ou5lEXWJmhnGgLsjGJqRtdHHhO/ay6oxOHYvEx4wtFXnKCkcXbZ550FsM05lvxICZKu1E1sBCphTySLTP35aMYm+O+31cIjT9di6qXx4TIXBzjqj0hWFwaRtcVX+9ivtr3kHmhA0N/ZYtHtwGlm8gtbA8GIkcOuZzHCNy1EmNvzElOBceEnYPiwSj5MhWhjYa9vUiOMrdJPGznvVCaiDv4NsuanYRPoeZNUEdYRRnIQKU4vDYuzI4mqf7Z592hkghLxhVRsDyVZayb3NLt1yIm7zpZPUOEnOieCaBPug1VHwavQpwxlvXnWXCrgeShb2WrTE634xlW3KnNL5JakOhDjzg1EoBH7Z2TJJS78UfhkyccotY8rx7JO8qS/TFxwbQQDxGJvshVeH+WuIZxmzUVTgfU39ZAslxXo7gBKLynw/LyUMpP7RY3396LL7CwtBX7bbb7ESw50Asz7gRb8vGeintbdfzR82+1ymxJVbQ2ZM4/qGfJcHJdUQ6s4F8wnx+RCbFQAYcsW67g2nVM9srY40ubbsgrjEtpqn9PlwT8Bmd7WKia6qB75fZ/IW9nrxAiFmtDHeW8178TmcTqK7B2f/OR1Tuwv5rryA6cVKTCsv4EP4LNsEWmBcDYLS4EfngCN14/CdhOdmer4aRN1xr66rnmnGD90A05PildgCHSptOoTmKQuSn9uzD/87+dvdMp/bzo9NdzhWr/o61Y0ajSOCnfa/LpRBSJY/8SyMPYCdRiKuTUlXiJwMZmZX+TlXjZCX+VxRQHptB7FS0nxbIvLF+DYBDRyFO9G0zMlBxqrKH9fOdXl1iD29ZHSLMCVXxSWxP+TgyiCG4ErOM7Ulp52/Q66vUZ3yHXEuBz0gD+RF7QDb8owSHEDQ0O4g8EXsC00LOoM++mbYGnxvNWVQz941yHYquptEtkuVzRWByQUUN616RXQd8K6l9o+M8Vs1rZz1l1LVn7DY5pCz3B90t2Re+DcEhcFEkoe5v+36cSp1jqGwoy7PRCnjTckuUD8dmreQBFRG9z18tBjw57zc5QMCG5lTTNMjiJAYB1vvtpFPy/5OAMn2zEBxJO1G/FKF9uBDt8jNWNV+6btT04RYu1hB/ltBgLOeGG4TeUJhOHF2w2IhO055rCYW19JzaCU678bB5TDC7wfUslbwZgc8F1aFDVHjk4lqNOAii9jUlk+yQwMf8TsmlwOEplD7Qz4/n20xI12GlNN7cmhc8+4sIrFPubHKqr4J5iUKX5ypf0AuKgVZgh5fV3Fv/Kf9HTfPjeDY6FyUfOr5i+Nw47DwkIulMVgUR6wrqon6D5EkCV6Vo11KCI90/NqVPvWw8y7+OCTLSE3CgC1J7JF9gZ3UzbVTeQ== X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf4a8f67-c9c4-4431-f734-08dca8a782e3 X-MS-Exchange-CrossTenant-AuthSource: PSAPR02MB4727.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2024 10:34:19.1041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4jiyg4KD24FZsps9riCwuih/5JuveIfJTkQtdvxwy+4ckWPtU1tfk94R9rWEE2Fz5VphL8iL7LyWxW4BnmRvlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR02MB5652 X-Headers-End: 1sV7Q7-0001pr-Bf Subject: [f2fs-dev] [PATCH] f2fs: free victim_secmap when pinned_secmap allocation fails X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yongpeng Yang via Linux-f2fs-devel From: Yongpeng Yang Reply-To: Yongpeng Yang Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In the init_victim_secmap function, if the allocation of dirty_i->pinned_secmap fails, dirty_i->victim_secmap is not freed, which can cause a memory leak. Signed-off-by: Yongpeng Yang --- fs/f2fs/segment.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 78c3198a6308..1e784ea3dbb4 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4971,8 +4971,10 @@ static int init_victim_secmap(struct f2fs_sb_info *sbi) return -ENOMEM; dirty_i->pinned_secmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL); - if (!dirty_i->pinned_secmap) + if (!dirty_i->pinned_secmap) { + kvfree(dirty_i->victim_secmap); return -ENOMEM; + } dirty_i->pinned_secmap_cnt = 0; dirty_i->enable_pin_section = true;