From 676d5d17dfbc7dc3c3a229ab763cf932850365f2 Mon Sep 17 00:00:00 2001 From: Nicholas Andrew Date: Sat, 19 Sep 2026 00:45:44 -0400 Subject: [PATCH] susfs: fix try_umount path reference lifetime --- fs/susfs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/susfs.c b/fs/susfs.c index 91840543b5b6..1efb3a619821 100644 --- a/fs/susfs.c +++ b/fs/susfs.c @@ -1172,8 +1172,13 @@ int susfs_sus_memfd(char *memfd_name) { static void umount_mnt(struct path *path, int flags) { int err = path_umount(path, flags); + + /* + * path_umount() consumes the path references, so do not + * dereference path after it returns. + */ if (err) { - SUSFS_LOGI("umount %s failed: %d\n", path->dentry->d_iname, err); + SUSFS_LOGI("umount failed: %d\n", err); } } @@ -1206,14 +1211,19 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) { if (path.dentry != path.mnt->mnt_root) { // it is not root mountpoint, maybe umounted by others already. + path_put(&path); return; } // we are only interest in some specific mounts if (check_mnt && !should_umount(&path)) { + path_put(&path); return; } - + + /* + * Successful handoff: path_umount() consumes these references. + */ umount_mnt(&path, flags); }