From: Eric Sesterhenn Date: Thu, 7 Dec 2006 04:33:47 +0000 (-0800) Subject: [PATCH] security/keys/*: user kmemdup() X-Git-Tag: v2.6.20-rc1~145^2^2~296 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=48ad504ee7d598431cb2d0b2f01c6d1aff1d2a07;p=linux-2.6-omap-h63xx.git [PATCH] security/keys/*: user kmemdup() Signed-off-by: Eric Sesterhenn Signed-off-by: Alexey Dobriyan Acked-By: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/security/keys/key.c b/security/keys/key.c index 0db816f10f8..ac9326c5f1d 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -290,11 +290,9 @@ struct key *key_alloc(struct key_type *type, const char *desc, goto no_memory_2; if (desc) { - key->description = kmalloc(desclen, GFP_KERNEL); + key->description = kmemdup(desc, desclen, GFP_KERNEL); if (!key->description) goto no_memory_3; - - memcpy(key->description, desc, desclen); } atomic_set(&key->usage, 1); diff --git a/security/keys/keyring.c b/security/keys/keyring.c index e8d02acc51e..ad45ce73964 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -706,12 +706,10 @@ int __key_link(struct key *keyring, struct key *key) BUG_ON(size > PAGE_SIZE); ret = -ENOMEM; - nklist = kmalloc(size, GFP_KERNEL); + nklist = kmemdup(klist, size, GFP_KERNEL); if (!nklist) goto error2; - memcpy(nklist, klist, size); - /* replace matched key */ atomic_inc(&key->usage); nklist->keys[loop] = key;