Skip to contentSkip to conversation

smb: client: add NULL check in automount_fullpath

PATCH In review Ruben Devos 2 participants 2 messages Jun 1, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smb: client: add NULL check in automount_fullpath

page is checked for null in __build_path_from_dentry_optional_prefix when tcon->origin_fullpath is not set. However, the check is missing when it is set.
Add a check to prevent a potential NULL pointer dereference.

---
 fs/smb/client/namespace.c | 3 +++
 1 file changed, 3 insertions(+)
fs/smb/client/namespace.c +3 -0
index e3f9213131c4..a6655807c086 100644
@@ -146,6 +146,9 @@ static char *automount_fullpath(struct dentry *dentry, void *page)
 	}
 	spin_unlock(&tcon->tc_lock);
 
+	if (unlikely(!page))
+		return ERR_PTR(-ENOMEM);
+
 	s = dentry_path_raw(dentry, page, PATH_MAX);
 	if (IS_ERR(s))
 		return s;
Signature · 1 line
2.49.0
#1 lore raw

good catch. Added to cifs-2.6.git for-next, and added Cc: stable

Quoted 29 lines · Ruben Devos

page is checked for null in __build_path_from_dentry_optional_prefix when tcon->origin_fullpath is not set. However, the check is missing when it is set.
Add a check to prevent a potential NULL pointer dereference.

---
 fs/smb/client/namespace.c | 3 +++
 1 file changed, 3 insertions(+)
fs/smb/client/namespace.c +3 -1
index e3f9213131c4..a6655807c086 100644
@@ -146,6 +146,9 @@ static char *automount_fullpath(struct dentry *dentry, void *page)
        }
        spin_unlock(&tcon->tc_lock);
 
+       if (unlikely(!page))
+               return ERR_PTR(-ENOMEM);
+
        s = dentry_path_raw(dentry, page, PATH_MAX);
        if (IS_ERR(s))
                return s;
--

2.49.0

Signature · 3 lines
Thanks,

Steve