Skip to content

Commit 87ea584

Browse files
ebiggersJames Morris
authored andcommitted
security: check for kstrdup() failure in lsm_append()
lsm_append() should return -ENOMEM if memory allocation failed. Fixes: d69dece ("LSM: Add /sys/kernel/security/lsm") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: James Morris <james.morris@microsoft.com>
1 parent 83a68a0 commit 87ea584

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

security/security.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ static int lsm_append(char *new, char **result)
118118

119119
if (*result == NULL) {
120120
*result = kstrdup(new, GFP_KERNEL);
121+
if (*result == NULL)
122+
return -ENOMEM;
121123
} else {
122124
/* Check if it is the last registered name */
123125
if (match_last_lsm(*result, new))

0 commit comments

Comments
 (0)