6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guanghui Yang <3497809730@qq.com> [ Upstream commit cca7d3e30bf30333314e31bc70b9a739f1342167 ] find_in_level() gets a dentry folio with f2fs_find_data_folio() before calling find_in_block(). If find_in_block() returns an error, the function stores the error in res_folio and breaks out of the loop without dropping the dentry folio. This leaks the folio reference on the find_in_block() error path. Drop the dentry folio before returning the error to the caller. Fixes: 7ad08a58bf67 ("f2fs: Handle casefolding with Encryption") Cc: stable@vger.kernel.org Reviewed-by: Chao Yu Signed-off-by: Guanghui Yang <3497809730@qq.com> Signed-off-by: Jaegeuk Kim [ Replaced f2fs_folio_put(dentry_folio, false) with f2fs_put_page(dentry_page, 0) for the page-based API. ] Signed-off-by: Sasha Levin --- fs/f2fs/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 13268d1f8c75a..570f79fa65a52 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -341,6 +341,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir, de = find_in_block(dir, dentry_page, fname, &max_slots, use_hash); if (IS_ERR(de)) { + f2fs_put_page(dentry_page, 0); *res_page = ERR_CAST(de); de = NULL; break; -- 2.53.0