Skip to content

Commit 19a1c40

Browse files
author
Al Viro
committed
fix the struct mount leak in umount_tree()
We need to drop everything we remove from the tree, whether mnt_has_parent() is true or not. Usually the bug manifests as a slow memory leak (leaked struct mount for initramfs); it becomes much more visible in mount_subtree() users, such as btrfs. There we leak a struct mount for btrfs superblock being mounted, which prevents fs shutdown on subsequent umount. Fixes: 56cbb42 ("switch the remnants of releasing the mountpoint away from fs_pin") Reported-by: Nikolay Borisov <[email protected]> Tested-by: Nikolay Borisov <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 18253e0 commit 19a1c40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/namespace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,18 +1463,18 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
14631463
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
14641464

14651465
disconnect = disconnect_mount(p, how);
1466-
14671466
if (mnt_has_parent(p)) {
14681467
mnt_add_count(p->mnt_parent, -1);
14691468
if (!disconnect) {
14701469
/* Don't forget about p */
14711470
list_add_tail(&p->mnt_child, &p->mnt_parent->mnt_mounts);
14721471
} else {
14731472
umount_mnt(p);
1474-
hlist_add_head(&p->mnt_umount, &unmounted);
14751473
}
14761474
}
14771475
change_mnt_propagation(p, MS_PRIVATE);
1476+
if (disconnect)
1477+
hlist_add_head(&p->mnt_umount, &unmounted);
14781478
}
14791479
}
14801480

0 commit comments

Comments
 (0)