Skip to contentSkip to conversation

keys: ensure that ->match_free() is called in request_key_and_link()

PATCH New Eric Biggers 1 participant 1 message Aug 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 keys: ensure that ->match_free() is called in request_key_and_link()

From: Eric Biggers <[email protected]>

If check_cached_key() returns a non-NULL value, we still need to call key_type::match_free() to undo key_type::match_preparse().

Fixes 7743c48e54ee ("keys: Cache result of request_key*() temporarily in task_struct")
---
 security/keys/request_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/request_key.c +1 -1
index 46c5187ce03f..6d628a5a8d10 100644
@@ -589,7 +589,7 @@ struct key *request_key_and_link(struct key_type *type,
 
 	key = check_cached_key(&ctx);
 	if (key)
-		return key;
+		goto error_free;
 
 	/* search all the process keyrings for a key */
 	rcu_read_lock();
Signature · 1 line
2.22.1