[PATCH] ksmbd: Avoid duplicate variable assignment in ksmbd_vfs_path_lookup()

Markus Elfring posted 1 patch 2 months, 2 weeks ago
fs/smb/server/vfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] ksmbd: Avoid duplicate variable assignment in ksmbd_vfs_path_lookup()
Posted by Markus Elfring 2 months, 2 weeks ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 4 Oct 2025 18:56:18 +0200

Move a variable assignment into an else branch so that the variable
will not be reassigned in case an empty string was detected in
this function implementation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/smb/server/vfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 891ed2dc2b73..bef6761760a4 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -73,7 +73,7 @@ static int ksmbd_vfs_path_lookup(struct ksmbd_share_config *share_conf,
 {
 	struct qstr last;
 	struct filename *filename __free(putname) = NULL;
-	const struct path *root_share_path = &share_conf->vfs_path;
+	const struct path *root_share_path;
 	int err, type;
 	struct dentry *d;
 
@@ -82,6 +82,7 @@ static int ksmbd_vfs_path_lookup(struct ksmbd_share_config *share_conf,
 		root_share_path = NULL;
 	} else {
 		flags |= LOOKUP_BENEATH;
+		root_share_path = &share_conf->vfs_path;
 	}
 
 	filename = getname_kernel(pathname);
-- 
2.51.0