Skip to contentSkip to conversation

smb: client: fix sbflags initialization

PATCH In review Arnd Bergmann 3 participants 3 messages Mar 6 – Mar 8

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

PATCH 1/1 smb: client: fix sbflags initialization

From: Arnd Bergmann <[email protected]>

The newly introduced variable is initialized in an #ifdef block but used outside of it, leading to undefined behavior when CONFIG_CIFS_ALLOW_INSECURE_LEGACY is disabled:

fs/smb/client/dir.c:417:9: error: variable 'sbflags' is uninitialized when used here [-Werror,-Wuninitialized]
417 | if (sbflags & CIFS_MOUNT_DYNPERM)
| ^~~~~~~

Move the initialization into the declaration, the same way as the other similar function do it.

Fixes 4fc3a433c139 ("smb: client: use atomic_t for mnt_cifs_flags")
---
 fs/smb/client/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/smb/client/dir.c +1 -2
index 953f1fee8cb8..55ffbdc17c8a 100644
@@ -187,7 +187,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 	const char *full_path;
 	void *page = alloc_dentry_path();
 	struct inode *newinode = NULL;
-	unsigned int sbflags;
+	unsigned int sbflags = cifs_sb_flags(cifs_sb);
 	int disposition;
 	struct TCP_Server_Info *server = tcon->ses->server;
 	struct cifs_open_parms oparms;
@@ -367,7 +367,6 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 	 * If Open reported that we actually created a file then we now have to
 	 * set the mode if possible.
 	 */
-	sbflags = cifs_sb_flags(cifs_sb);
 	if ((tcon->unix_ext) && (*oplock & CIFS_CREATE_ACTION)) {
 		struct cifs_unix_set_info_args args = {
 				.mode	= mode,
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly introduced variable is initialized in an #ifdef block but used outside of it, leading to undefined behavior when CONFIG_CIFS_ALLOW_INSECURE_LEGACY is disabled:

fs/smb/client/dir.c:417:9: error: variable 'sbflags' is uninitialized when used here [-Werror,-Wuninitialized]
417 | if (sbflags & CIFS_MOUNT_DYNPERM)
| ^~~~~~~

Quoted 8 lines

Move the initialization into the declaration, the same way as the other similar function do it.

Fixes 4fc3a433c139 ("smb: client: use atomic_t for mnt_cifs_flags")
---
 fs/smb/client/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
#2 lore raw

Good catch.

Added the Reviewed-by and merged into cifs-2.6.git for-next

Quoted 24 lines · Paulo Alcantara
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The newly introduced variable is initialized in an #ifdef block but used outside of it, leading to undefined behavior when CONFIG_CIFS_ALLOW_INSECURE_LEGACY is disabled:

fs/smb/client/dir.c:417:9: error: variable 'sbflags' is uninitialized when used here [-Werror,-Wuninitialized]
417 | if (sbflags & CIFS_MOUNT_DYNPERM)
| ^~~~~~~

Quoted 8 lines

Move the initialization into the declaration, the same way as the other similar function do it.

Fixes 4fc3a433c139 ("smb: client: use atomic_t for mnt_cifs_flags")
---
 fs/smb/client/dir.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Signature · 3 lines
Thanks,

Steve