]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
landlock: Improve variable scope
authorMickaël Salaün <mic@digikod.net>
Fri, 28 Nov 2025 17:21:57 +0000 (18:21 +0100)
committerMickaël Salaün <mic@digikod.net>
Fri, 28 Nov 2025 17:27:06 +0000 (18:27 +0100)
This is now possible thanks to the disconnected directory fix.

Cc: Günther Noack <gnoack@google.com>
Cc: Song Liu <song@kernel.org>
Cc: Tingmao Wang <m@maowtm.org>
Link: https://lore.kernel.org/r/20251128172200.760753-3-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
security/landlock/fs.c

index 2521acde6039f5f3a5fdaba30a4bc2f6aae26ef1..6fadb54496a06b7c40049b519aa568f595dc5011 100644 (file)
@@ -838,7 +838,6 @@ static bool is_access_to_paths_allowed(
         * restriction.
         */
        while (true) {
-               struct dentry *parent_dentry;
                const struct landlock_rule *rule;
 
                /*
@@ -931,7 +930,9 @@ jump_up:
                        walker_path.dentry = walker_path.mnt->mnt_root;
                        dget(walker_path.dentry);
                } else {
-                       parent_dentry = dget_parent(walker_path.dentry);
+                       struct dentry *const parent_dentry =
+                               dget_parent(walker_path.dentry);
+
                        dput(walker_path.dentry);
                        walker_path.dentry = parent_dentry;
                }