Skip to contentSkip to conversation

cifs: uninitialized variable in cifs_get_next_mid()

PATCH In review Dan Carpenter 2 participants 2 messages Jan 11, 2022

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

PATCH 1/1 cifs: uninitialized variable in cifs_get_next_mid()

The "reconnect" was never initialized to false.

Fixes 220c5bc25d87 ("cifs: take cifs_tcp_ses_lock for status checks")
---
 fs/cifs/smb1ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smb1ops.c +2 -1
index 54319a789c92..6b1b048b36ae 100644
@@ -163,7 +163,8 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
 {
 	__u64 mid = 0;
 	__u16 last_mid, cur_mid;
-	bool collision, reconnect;
+	bool reconnect = false;
+	bool collision;
 
 	spin_lock(&GlobalMid_Lock);
 
Signature · 1 line
2.20.1
#1 lore raw

That was fixed similarly a couple of days ago by a patch from Enzo

commit 1913e1116a3174648cf2e6faedf29204f31cc438

Author: Enzo Matsumiya <[email protected]>
Date:   Fri Jan 7 19:51:39 2022 -0300

cifs: fix hang on cifs_get_next_mid()

Mount will hang if using SMB1 and DFS.

This is because every call to get_next_mid() will, unconditionally, mark tcpStatus to CifsNeedReconnect before even establishing the initial connect, because "reconnect" variable was not initialized.

Quoted 27 lines · Dan Carpenter via samba-technical

The "reconnect" was never initialized to false.

Fixes 220c5bc25d87 ("cifs: take cifs_tcp_ses_lock for status checks")
---
 fs/cifs/smb1ops.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smb1ops.c +2 -2
index 54319a789c92..6b1b048b36ae 100644
@@ -163,7 +163,8 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
 {
        __u64 mid = 0;
        __u16 last_mid, cur_mid;
-       bool collision, reconnect;
+       bool reconnect = false;
+       bool collision;
 
        spin_lock(&GlobalMid_Lock);
 
--

2.20.1

Signature · 3 lines
Thanks,

Steve