Re: [PATCH v3 0/2] hfsplus, hfs: fix B-tree node leak on hfs_btree_open() error path

From: Viacheslav Dubeyko

Date: Fri Oct 02 2026 - 14:18:59 EST


On Thu, 2026-10-01 at 23:38 +0200, Mahmut Emin Kurhan wrote:
> This is v3 of the hfsplus/hfs B-tree node leak fix, rebased onto the
> for-next branch of the HFS/HFS+ tree as requested.
>
> The leak is unchanged: hfs_btree_open() can fail after the head node
> has
> been inserted into tree->node_hash, and the error path does a bare
> kfree(tree) without freeing the hashed nodes. The fix factors the
> node-hash freeing out of hfs_btree_close() into hfs_bnode_hash_free()
> and
> calls it from both hfs_btree_close() and the hfs_btree_open() error
> path.
>
> Changes since v2:
>  - rebased on for-next; the extracted helper now wraps the hash_lock
>    serialized close loop introduced by commit dce0e0248205
> ("hfs/hfsplus:
>    serialize B-tree close against folio release") (Slava Dubeyko)
>  - on the open error path the tree is not published yet, so the lock
> is
>    uncontended but kept for consistency
>  - no functional change to the leak fix itself
>
> v2:
> https://lore.kernel.org/linux-fsdevel/20260930232312.1405042-1-guvenlik@xxxxxxxxxx
>
> Mahmut Emin Kurhan (2):
>   hfsplus: free cached B-tree nodes on hfs_btree_open() error path
>   hfs: free cached B-tree nodes on hfs_btree_open() error path
>
>  fs/hfs/btree.c     | 40 +++++++++++++++++++++++-----------------
>  fs/hfsplus/btree.c | 41 +++++++++++++++++++++++------------------
>  2 files changed, 46 insertions(+), 35 deletions(-)

The patchset looks reasonable to me. Let me run xfstests for the
patchset. I'll share the results ASAP.

Thanks,
Slava.