* [PATCH] security: keyring: remove redundant NULL check
@ 2011-01-24 15:37 Davidlohr Bueso
2011-01-25 14:35 ` David Howells
0 siblings, 1 reply; 2+ messages in thread
From: Davidlohr Bueso @ 2011-01-24 15:37 UTC (permalink / raw)
To: David Howells, LKML; +Cc: keyrings
From: Davidlohr Bueso <dave@gnu.org>
Date: Sun, 23 Jan 2011 22:01:20 -0300
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
security/keys/keyring.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index d37f713..cb8110b 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -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);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] security: keyring: remove redundant NULL check
2011-01-24 15:37 [PATCH] security: keyring: remove redundant NULL check Davidlohr Bueso
@ 2011-01-25 14:35 ` David Howells
0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2011-01-25 14:35 UTC (permalink / raw)
To: Davidlohr Bueso; +Cc: dhowells, LKML, keyrings
Davidlohr Bueso <dave@gnu.org> wrote:
> - 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-25 14:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24 15:37 [PATCH] security: keyring: remove redundant NULL check Davidlohr Bueso
2011-01-25 14:35 ` David Howells
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.