]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cifs: fix NULL dereference in smb2_check_message()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 22 Jun 2021 10:59:55 +0000 (13:59 +0300)
committerSteve French <stfrench@microsoft.com>
Wed, 23 Jun 2021 18:04:36 +0000 (13:04 -0500)
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>
fs/cifs/smb2misc.c

index c6bb2ea1983ba41f28db6fa00d9244d5828871cf..668f7710883184129816e955274309fc3d818d18 100644 (file)
@@ -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;
                }