]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
security: check for kstrdup() failure in lsm_append()
authorEric Biggers <ebiggers@google.com>
Tue, 17 Jul 2018 17:36:04 +0000 (10:36 -0700)
committerJames Morris <james.morris@microsoft.com>
Wed, 18 Jul 2018 04:27:06 +0000 (21:27 -0700)
lsm_append() should return -ENOMEM if memory allocation failed.

Fixes: d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: James Morris <james.morris@microsoft.com>
security/security.c

index 6e149d0ffe333934c9efb628183df7f40082990d..b49ee810371bee5891f9ebe5fc2f091f1fe2e442 100644 (file)
@@ -118,6 +118,8 @@ static int lsm_append(char *new, char **result)
 
        if (*result == NULL) {
                *result = kstrdup(new, GFP_KERNEL);
+               if (*result == NULL)
+                       return -ENOMEM;
        } else {
                /* Check if it is the last registered name */
                if (match_last_lsm(*result, new))