Skip to content

Commit

Permalink
[PATCH] security/keys/*: user kmemdup()
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Sesterhenn <[email protected]>
Signed-off-by: Alexey Dobriyan <[email protected]>
Acked-By: David Howells <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
SesterhennEric authored and Linus Torvalds committed Dec 7, 2006
1 parent 7cf9c2c commit 48ad504
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions security/keys/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions security/keys/keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 48ad504

Please sign in to comment.