diff mbox

KEYS: potential uninitialized variable

Message ID 20160526064559.GA6738@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 26, 2016, 6:45 a.m. UTC
If __key_link_begin() failed then "edit" would be uninitialized.  I've
added a check to fix that.

Fixes: f70e2e06196a ('KEYS: Do preallocation for __key_link()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Howells May 27, 2016, 2:02 p.m. UTC | #1
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> If __key_link_begin() failed then "edit" would be uninitialized.  I've
> added a check to fix that.
> 
> Fixes: f70e2e06196a ('KEYS: Do preallocation for __key_link()')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/security/keys/key.c b/security/keys/key.c
index bd5a272..346fbf2 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -597,7 +597,7 @@  int key_reject_and_link(struct key *key,
 
 	mutex_unlock(&key_construction_mutex);
 
-	if (keyring)
+	if (keyring && link_ret == 0)
 		__key_link_end(keyring, &key->index_key, edit);
 
 	/* wake up anyone waiting for a key to be constructed */