[PATCH] security/keys/*: user kmemdup()
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>
This commit is contained in:
committed by
Linus Torvalds
parent
7cf9c2c76c
commit
48ad504ee7
@@ -290,11 +290,9 @@ struct key *key_alloc(struct key_type *type, const char *desc,
|
|||||||
goto no_memory_2;
|
goto no_memory_2;
|
||||||
|
|
||||||
if (desc) {
|
if (desc) {
|
||||||
key->description = kmalloc(desclen, GFP_KERNEL);
|
key->description = kmemdup(desc, desclen, GFP_KERNEL);
|
||||||
if (!key->description)
|
if (!key->description)
|
||||||
goto no_memory_3;
|
goto no_memory_3;
|
||||||
|
|
||||||
memcpy(key->description, desc, desclen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_set(&key->usage, 1);
|
atomic_set(&key->usage, 1);
|
||||||
|
@@ -706,12 +706,10 @@ int __key_link(struct key *keyring, struct key *key)
|
|||||||
BUG_ON(size > PAGE_SIZE);
|
BUG_ON(size > PAGE_SIZE);
|
||||||
|
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
nklist = kmalloc(size, GFP_KERNEL);
|
nklist = kmemdup(klist, size, GFP_KERNEL);
|
||||||
if (!nklist)
|
if (!nklist)
|
||||||
goto error2;
|
goto error2;
|
||||||
|
|
||||||
memcpy(nklist, klist, size);
|
|
||||||
|
|
||||||
/* replace matched key */
|
/* replace matched key */
|
||||||
atomic_inc(&key->usage);
|
atomic_inc(&key->usage);
|
||||||
nklist->keys[loop] = key;
|
nklist->keys[loop] = key;
|
||||||
|
Reference in New Issue
Block a user