Skip to content

Commit

Permalink
security: check for kstrdup() failure in lsm_append()
Browse files Browse the repository at this point in the history
lsm_append() should return -ENOMEM if memory allocation failed.

Fixes: d69dece ("LSM: Add /sys/kernel/security/lsm")
Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
ebiggers authored and James Morris committed Jul 18, 2018
1 parent 83a68a0 commit 87ea584
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 87ea584

Please sign in to comment.