Skip to contentSkip to conversation

KEYS: Fix an error code in request_master_key()

PATCH In review Dan Carpenter 3 participants 4 messages Dec 16, 2016 – Jan 16, 2017

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

PATCH 1/1 KEYS: Fix an error code in request_master_key()

This function has two callers and neither are able to handle a NULL return. Really, -EINVAL is the correct thing return here anyway. This fixes some static checker warnings like:

security/keys/encrypted-keys/encrypted.c:709 encrypted_key_decrypt()
error: uninitialized symbol 'master_key'.

Fixes 7e70cb497850 ("keys: add new key-type encrypted")
security/keys/encrypted-keys/encrypted.c +1 -1
index 17a06105ccb6..d7a4969b2dd3 100644
@@ -437,7 +437,7 @@ static struct skcipher_request *init_skcipher_req(const u8 *key,
 static struct key *request_master_key(struct encrypted_key_payload *epayload,
 				      const u8 **master_key, size_t *master_keylen)
 {
-	struct key *mkey = NULL;
+	struct key *mkey = ERR_PTR(-EINVAL);
 
 	if (!strncmp(epayload->master_desc, KEY_TRUSTED_PREFIX,
 		     KEY_TRUSTED_PREFIX_LEN)) {
#1 lore raw

Hi Dan,

Quoted 9 lines · Dan Carpenter

This function has two callers and neither are able to handle a NULL return. Really, -EINVAL is the correct thing return here anyway. This fixes some static checker warnings like:

security/keys/encrypted-keys/encrypted.c:709 encrypted_key_decrypt()
error: uninitialized symbol 'master_key'.

Fixes 7e70cb497850 ("keys: add new key-type encrypted")

Thanks!

Mimi

Quoted 14 lines
security/keys/encrypted-keys/encrypted.c +1 -1
index 17a06105ccb6..d7a4969b2dd3 100644
@@ -437,7 +437,7 @@ static struct skcipher_request *init_skcipher_req(const u8 *key,
 static struct key *request_master_key(struct encrypted_key_payload *epayload,
 				      const u8 **master_key, size_t *master_keylen)
 {
-	struct key *mkey = NULL;
+	struct key *mkey = ERR_PTR(-EINVAL);
 
 	if (!strncmp(epayload->master_desc, KEY_TRUSTED_PREFIX,
 		     KEY_TRUSTED_PREFIX_LEN)) {
maintainer
#2 lore raw
Quoted 5 lines · Mimi Zohar
Quoted 4 lines · Dan Carpenter

This function has two callers and neither are able to handle a NULL return. Really, -EINVAL is the correct thing return here anyway. This fixes some static checker warnings like:

Quoted 7 lines
Quoted 5 lines

security/keys/encrypted-keys/encrypted.c:709 encrypted_key_decrypt()
error: uninitialized symbol 'master_key'.

Fixes 7e70cb497850 ("keys: add new key-type encrypted")

Thanks!

Can I put that down as an Acked-by or Reviewed-by?

David

#3 lore raw
Quoted 10 lines · David Howells
Quoted 8 lines · Mimi Zohar
Quoted 7 lines · Dan Carpenter

This function has two callers and neither are able to handle a NULL return. Really, -EINVAL is the correct thing return here anyway. This fixes some static checker warnings like:

security/keys/encrypted-keys/encrypted.c:709 encrypted_key_decrypt()
error: uninitialized symbol 'master_key'.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 7e70cb497850 ("keys: add new key-type encrypted")

Thanks!

Can I put that down as an Acked-by or Reviewed-by?

Feel free to add by "Acked-by" on both this patch and Dan's other patch "KEYS: Use memzero_explicit() for secret data".

Mimi