]> err.no Git - linux-2.6/commitdiff
[PATCH] security/keys/*: user kmemdup()
authorEric Sesterhenn <snakebyte@gmx.de>
Thu, 7 Dec 2006 04:33:47 +0000 (20:33 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Thu, 7 Dec 2006 16:39:25 +0000 (08:39 -0800)
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-By: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
security/keys/key.c
security/keys/keyring.c

index 0db816f10f8575e718186faa47140bcbe8e01bc8..ac9326c5f1da3f1e1781d8654ac816bb83355560 100644 (file)
@@ -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);
index e8d02acc51e7180f23a31b849ccce820418fd55c..ad45ce73964b193db630606c2d302dd6414f57c9 100644 (file)
@@ -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;