Skip to contentSkip to conversation

f2fs: fix ifolio leak in f2fs_get_new_data_folio

PATCH Superseded Guanghui Yang 1 participant 1 message Jul 13 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix ifolio leak in f2fs_get_new_data_folio

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, this leaves the extra inode folio reference held by the caller.

Release ifolio before returning from the f2fs_reserve_block() failure path.

---
 fs/f2fs/data.c | 1 +
 1 file changed, 1 insertion(+)
fs/f2fs/data.c +1 -0
index a765fda71536..e66aefc573d9 100644
@@ -1477,6 +1477,7 @@ struct folio *f2fs_get_new_data_folio(struct inode *inode,
 	err = f2fs_reserve_block(&dn, index);
 	if (err) {
 		f2fs_folio_put(folio, true);
+		f2fs_folio_put(ifolio, true);
 		return ERR_PTR(err);
 	}
 	if (!ifolio)

base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa

Signature · 8 lines
2.52.0.windows.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel