Skip to content

Commit fae1133

Browse files
arndbsmfrench
authored andcommitted
smb: client: fix sbflags initialization
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: 4fc3a43 ("smb: client: use atomic_t for mnt_cifs_flags") Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 4a7d272 commit fae1133

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

fs/smb/client/dir.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
187187
const char *full_path;
188188
void *page = alloc_dentry_path();
189189
struct inode *newinode = NULL;
190-
unsigned int sbflags;
190+
unsigned int sbflags = cifs_sb_flags(cifs_sb);
191191
int disposition;
192192
struct TCP_Server_Info *server = tcon->ses->server;
193193
struct cifs_open_parms oparms;
@@ -368,7 +368,6 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
368368
* If Open reported that we actually created a file then we now have to
369369
* set the mode if possible.
370370
*/
371-
sbflags = cifs_sb_flags(cifs_sb);
372371
if ((tcon->unix_ext) && (*oplock & CIFS_CREATE_ACTION)) {
373372
struct cifs_unix_set_info_args args = {
374373
.mode = mode,

0 commit comments

Comments
 (0)