From f7ef7de6b9bcec1314af2cdcfd0c952eadd6a779 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micka=C3=ABl=20Sala=C3=BCn?= Date: Fri, 28 Nov 2025 18:21:57 +0100 Subject: [PATCH] landlock: Improve variable scope MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is now possible thanks to the disconnected directory fix. Cc: Günther Noack Cc: Song Liu Cc: Tingmao Wang Link: https://lore.kernel.org/r/20251128172200.760753-3-mic@digikod.net Signed-off-by: Mickaël Salaün --- security/landlock/fs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 2521acde6039f..6fadb54496a06 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -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; } -- 2.47.3