diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e15b09457a96e75dec028572d4abee575b5c07dd..b6bb82ec278e9c854ea9fd167aee86a883a94e6d 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1605,6 +1605,7 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol)
 				    MAX_USERNAME_SIZE))
 				continue;
 			if (strlen(vol->username) != 0 &&
+			    ses->password != NULL &&
 			    strncmp(ses->password,
 				    vol->password ? vol->password : "",
 				    MAX_PASSWORD_SIZE))