Преглед на файлове

security: check for kstrdup() failure in lsm_append()

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>
Eric Biggers преди 7 години
родител
ревизия
87ea584332
променени са 1 файла, в които са добавени 2 реда и са изтрити 0 реда
  1. 2 0
      security/security.c

+ 2 - 0
security/security.c

@@ -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))