Reference/memory leaks on common paths: same-directory rename, hard-link query, create_subvol, etc.
Audit findings against master @ a0648190 (v1.10). A few of the more reachable leaks; all were verified against the free_fcb/free_fileref/reap_* ownership semantics.
Same-directory rename leaks a fileref reference every time — src/fileinfo.c
set_rename_information:relatedgets a reference (~3136/3139, or fromopen_filerefat ~3176) butend:only releases it on failure (if (!NT_SUCCESS(Status) && related) free_fileref(related);, ~3255-3256). The cross-directory / cross-subvol callees take ownership viafileref->parent = related, butrename_in_same_directorydoes not touchparent, so on the success path the reference is never dropped — the directory's fileref/fcb can never be reaped until dismount.Hard-link query leaks when a parent is marked deleted — src/fileinfo.c
fill_in_hard_link_information(~4942) andfill_in_hard_link_full_id_information(~5112):free_fileref(parfr)sits inside theelse if (!parfr->deleted)block, so whenopen_fileref_by_inodesucceeds but the parent is deleted, its reference leaks. Also,fill_in_hard_link_full_id_informationdereferencesfr2->dc->index(~5064) without thefr2->dc &&guard its sibling has (~4897) — dummy filerefs havedc == NULL(NULL deref).create_subvolnever freesutf8.Buffer— src/fsctl.c ~838 (allocation) to ~1136-1157 (end): unlikecreate_snapshot(~732) andmknod(~4159), every exit path leaks it. Any user with FILE_ADD_SUBDIRECTORY on a directory can loop this to drain PagedPool.open_fileref_childstreampart race leaks an fcb reference — src/create.c ~1594-1610: whendc->filerefwas set concurrently,duff_fris freed directly (ExFreeToPagedLookasideList) while the fcb reference taken at ~1582 is never dropped. The non-stream branch handles this correctly (sf2->fcb = fcbat ~1667 +reap_fileref(duff_fr)at ~1688, whosefree_fcbbalances it).Mount-failure cleanup — src/btrfs.c
mount_volexit path (~5066-5118) leaks roots/trees/chunks/sys_chunks/dummy_fcb/batch list, and deletes the lookaside lists beforereap_fcbruns (so reaped fcbs go back into already-deleted lookasides). Repeatedly mounting a crafted image that fails late drains kernel memory.
There are ~25 more insert_tree_item failure-path leaks in extent-tree.c and a handful in flushthread.c / balance.c / send.c of the same shape (the function does not take ownership of data on failure, but the callers just return) — happy to provide the full list if useful.
Source: maharmstone/btrfs