security: keyring: remove redundant NULL check
Subsystems (2)
PATCH 1/1 security: keyring: remove redundant NULL check
From: Davidlohr Bueso <[email protected]>
Date: Sun, 23 Jan 2011 22:01:20 -0300
Signed-off-by Davidlohr Bueso <[email protected]>
--- security/keys/keyring.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
security/keys/keyring.c +4 -5
@@ -866,11 +866,10 @@ void __key_link_end(struct key *keyring, struct key_type *type,if (type == &key_type_keyring)up_write (&keyring_serialise_link_sem); -if (prealloc) { -kfree (prealloc); -key_payload_reserve (keyring, - keyring->datalen -KEYQUOTA_LINK_BYTES ); - } +kfree (prealloc); +key_payload_reserve (keyring, + keyring->datalen -KEYQUOTA_LINK_BYTES ); +up_write (&keyring->sem); }
Signature · 1 line
1.7.1
David Howells
maintainersecurity/keys/keyring.c void __key_link_end(struct key *keyring, struct key_type *type, · line 872
Quoted 9 lines · Davidlohr Bueso
security/keys/keyring.c +4
-5-if (prealloc) { -kfree (prealloc); -key_payload_reserve (keyring, - keyring->datalen -KEYQUOTA_LINK_BYTES ); - } +kfree (prealloc); +key_payload_reserve (keyring, + keyring->datalen -KEYQUOTA_LINK_BYTES ); +
This is not correct, since you'd be removing the quota allocation for the new link in the case that __key_link() was called (and cleared *_prealloc).
However, the upstream code isn't correct either, since the preallocation may not have extended the reservation at all (if it decided to displace a key rather than adding a key).
David