From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DFCD227BB5 for ; Sun, 19 Jul 2026 07:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784445288; cv=none; b=kBRu0+oxbqTKd2pn2hNlWKsnD8chERtzVcSQiyzDVAqZNF7b2zdw61bUWvAgNbR6jEmKXx+9OUEBYwX2YfwppnEIczGVe6uq5/qs78rAwUci6bLgR7Oo6RE3BsXK/V5SvvQ/0+090G9y7Y94IO3Hy/sZlViVqJPuDCBYw7gKO/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784445288; c=relaxed/simple; bh=8P8zbOvk+XSjIBHYDpRTqCMm07Qjd1srsDf+CwNXXIc=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=d3hCsg2u6PQUZ0t+N9xN/oF66hAnuMyqD6Y2Ufk3G7MFHM+K8jvgMV1jV+C+qXehteIP4IBfgSv0dmtLVgj3nZWuf6meOKvzflL9abnAI3WZOH8AOu26kmzFSOh4jrzUWl4dl7i9FX8w0MnEBp2gXPi51WJCRxdsEGwAuBn+4Vg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DeExQbfJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DeExQbfJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C5AF1F000E9; Sun, 19 Jul 2026 07:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784445286; bh=gWU93m+dehCCRAWw73kWCKHBJGHjBIGOnCPrX//nidA=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=DeExQbfJ7KG37rZyh3fWy/nEZVe6uTTBacDCFpiWgq06Ky2PXlKg1C4EusXuTtxMQ 6HTYoBP7uCL6Dus9gwyvhMlf1nVWB2RR5+0GKsQn4v8j1l2DWdT5pJKwvyfZjsKb82 sfI2hgeoshmUzk1KJjEhjTjkGLzPLze+J1vg/PrmELhz/R/QJiWs/JSTyFiR9F9Uzu y+1cOibB6oY/fZ1YHDMHIxX54Tsncs7kp6F7tStpO02QRxuZCpb+w6ePuues5ndahr 6ELd/S08jgBLFdxhH5PeP2ZXLMJ/QIQ8p0ncUEE0Iy9+3HbMiIDrHqxijV5vysX1UC zrs7sDO+0aQwA== Message-ID: Date: Sun, 19 Jul 2026 15:14:43 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] f2fs: fix ifolio leak in f2fs_get_new_data_folio To: Guanghui Yang <3497809730@qq.com>, Jaegeuk Kim References: <20260713055959.1865-1-3497809730@qq.com> Content-Language: en-US From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/13/26 14:16, Guanghui Yang wrote: > f2fs_get_new_data_folio() documents that ifolio is only set by > make_empty_dir(), and that ifolio should be released by this function on > any error. > > The allocation failure path already follows this rule, but the > f2fs_reserve_block() failure path only drops the newly grabbed folio and > returns the error. When make_empty_dir() passes a non-NULL ifolio, an > early f2fs_reserve_block() failure can leave the extra inode folio > reference held by the caller. > > Release ifolio on this error path if f2fs_reserve_block() has not already > cleared dn.inode_folio. > > Signed-off-by: Guanghui Yang <3497809730@qq.com> > --- > > Changes since v1: > - Check dn.inode_folio before releasing ifolio to avoid a double put when > f2fs_reserve_block() has already cleared the dnode. > > fs/f2fs/data.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index a765fda71536..6c573d392dac 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1477,6 +1477,8 @@ struct folio *f2fs_get_new_data_folio(struct inode *inode, > err = f2fs_reserve_block(&dn, index); > if (err) { > f2fs_folio_put(folio, true); > + if (dn.inode_folio) > + f2fs_folio_put(ifolio, true); No, caller will handle it. > return ERR_PTR(err); > } > if (!ifolio) > > base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa