summaryrefslogtreecommitdiff
path: root/fs/cifs
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-06-22 13:59:55 +0300
committerSteve French <stfrench@microsoft.com>2021-06-23 13:04:36 -0500
commit1689b0b554defd5a7863bbd434ae911b8869504a (patch)
treeeca597e9d62614365c4bd55c032372d928e709be /fs/cifs
parent0555b221528e9cb11f5766dcdee19c809187e42e (diff)
cifs: fix NULL dereference in smb2_check_message()
This code sets "ses" to NULL which will lead to a NULL dereference on the second iteration through the loop. Fixes: 85346c17e425 ("cifs: convert list_for_each to entry variant in smb2misc.c") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/smb2misc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index c6bb2ea1983b..668f77108831 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -158,11 +158,10 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) {
if (ses->Suid == thdr->SessionId)
break;
-
- ses = NULL;
}
spin_unlock(&cifs_tcp_ses_lock);
- if (ses == NULL) {
+ if (list_entry_is_head(ses, &srvr->smb_ses_list,
+ smb_ses_list)) {
cifs_dbg(VFS, "no decryption - session id not found\n");
return 1;
}