summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-04-12 17:01:01 +0100
committerJarkko Sakkinen <jarkko@kernel.org>2021-04-14 16:30:31 +0300
commitaec00aa04b1131e17e6744681b380779f89d77b3 (patch)
treeca25ca1f1a11057bcdf5937e47f15875fd1da6af /security
parent3d785d73b4c1014839d9f9af0ee526f8d5706a73 (diff)
KEYS: trusted: Fix missing null return from kzalloc call
The kzalloc call can return null with the GFP_KERNEL flag so add a null check and exit via a new error exit label. Use the same exit error label for another error path too. Addresses-Coverity: ("Dereference null return value") Fixes: 830027e2cb55 ("KEYS: trusted: Add generic trusted keys framework") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Diffstat (limited to 'security')
-rw-r--r--security/keys/trusted-keys/trusted_core.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c
index ec3a066a4b42..90774793f0b1 100644
--- a/security/keys/trusted-keys/trusted_core.c
+++ b/security/keys/trusted-keys/trusted_core.c
@@ -116,11 +116,13 @@ static struct trusted_key_payload *trusted_payload_alloc(struct key *key)
ret = key_payload_reserve(key, sizeof(*p));
if (ret < 0)
- return p;
+ goto err;
p = kzalloc(sizeof(*p), GFP_KERNEL);
+ if (!p)
+ goto err;
p->migratable = migratable;
-
+err:
return p;
}