]> Git Repo - linux.git/commitdiff
cifs: check kmalloc before use
authorNicholas Mc Guire <[email protected]>
Thu, 23 Aug 2018 10:24:02 +0000 (12:24 +0200)
committerSteve French <[email protected]>
Thu, 23 Aug 2018 20:10:49 +0000 (15:10 -0500)
The kmalloc was not being checked - if it fails issue a warning
and return -ENOMEM to the caller.

Signed-off-by: Nicholas Mc Guire <[email protected]>
Fixes: b8da344b74c8 ("cifs: dynamic allocation of ntlmssp blob")
Signed-off-by: Steve French <[email protected]>
Reviewed-by: Pavel Shilovsky <[email protected]>
cc: Stable <[email protected]>`

fs/cifs/sess.c

index 8b0502cd39afb6b27f89b24fdb63e8122f162aee..aa23c00367ec4644118090a73d5f9eb995229555 100644 (file)
@@ -398,6 +398,12 @@ int build_ntlmssp_auth_blob(unsigned char **pbuffer,
                goto setup_ntlmv2_ret;
        }
        *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL);
+       if (!*pbuffer) {
+               rc = -ENOMEM;
+               cifs_dbg(VFS, "Error %d during NTLMSSP allocation\n", rc);
+               *buflen = 0;
+               goto setup_ntlmv2_ret;
+       }
        sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer;
 
        memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8);
This page took 0.063091 seconds and 4 git commands to generate.