Skip to content

Commit

Permalink
KEYS: use kvfree() in add_key
Browse files Browse the repository at this point in the history
There is no need to make a flag to tell that this memory is allocated by
kmalloc or vmalloc. Just use kvfree to free the memory.

Signed-off-by: Geliang Tang <[email protected]>
Signed-off-by: David Howells <[email protected]>
  • Loading branch information
geliangtang authored and dhowells committed Oct 21, 2015
1 parent 09302fd commit d0e0eba
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions security/keys/keyctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
char type[32], *description;
void *payload;
long ret;
bool vm;

ret = -EINVAL;
if (plen > 1024 * 1024 - 1)
Expand Down Expand Up @@ -98,14 +97,12 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
/* pull the payload in if one was supplied */
payload = NULL;

vm = false;
if (_payload) {
ret = -ENOMEM;
payload = kmalloc(plen, GFP_KERNEL | __GFP_NOWARN);
if (!payload) {
if (plen <= PAGE_SIZE)
goto error2;
vm = true;
payload = vmalloc(plen);
if (!payload)
goto error2;
Expand Down Expand Up @@ -138,10 +135,7 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,

key_ref_put(keyring_ref);
error3:
if (!vm)
kfree(payload);
else
vfree(payload);
kvfree(payload);
error2:
kfree(description);
error:
Expand Down

0 comments on commit d0e0eba

Please sign in to comment.