[PATCH] security: keys: add NULL checking for key->type->instantiate
Geliang Tang
geliangtang at gmail.com
Fri Jan 25 07:16:14 UTC 2019
key->type->instantiate can be NULL, add NULL checking to prevent
NULL pointer dereference in __key_instantiate_and_link().
Signed-off-by: Geliang Tang <geliangtang at gmail.com>
---
security/keys/key.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/security/keys/key.c b/security/keys/key.c
index 44a80d6741a1..ae3cc11be0d2 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -438,7 +438,8 @@ static int __key_instantiate_and_link(struct key *key,
/* can't instantiate twice */
if (key->state == KEY_IS_UNINSTANTIATED) {
/* instantiate the key */
- ret = key->type->instantiate(key, prep);
+ if (key->type->instantiate)
+ ret = key->type->instantiate(key, prep);
if (ret == 0) {
/* mark the key as being instantiated */
--
2.17.1
More information about the Linux-security-module-archive
mailing list