提交 d0e0eba0 编写于 作者: G Geliang Tang 提交者: David Howells

KEYS: use kvfree() in add_key

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: NGeliang Tang <geliangtang@163.com>
Signed-off-by: NDavid Howells <dhowells@redhat.com>
上级 09302fd1
...@@ -67,7 +67,6 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type, ...@@ -67,7 +67,6 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
char type[32], *description; char type[32], *description;
void *payload; void *payload;
long ret; long ret;
bool vm;
ret = -EINVAL; ret = -EINVAL;
if (plen > 1024 * 1024 - 1) if (plen > 1024 * 1024 - 1)
...@@ -98,14 +97,12 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type, ...@@ -98,14 +97,12 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
/* pull the payload in if one was supplied */ /* pull the payload in if one was supplied */
payload = NULL; payload = NULL;
vm = false;
if (_payload) { if (_payload) {
ret = -ENOMEM; ret = -ENOMEM;
payload = kmalloc(plen, GFP_KERNEL | __GFP_NOWARN); payload = kmalloc(plen, GFP_KERNEL | __GFP_NOWARN);
if (!payload) { if (!payload) {
if (plen <= PAGE_SIZE) if (plen <= PAGE_SIZE)
goto error2; goto error2;
vm = true;
payload = vmalloc(plen); payload = vmalloc(plen);
if (!payload) if (!payload)
goto error2; goto error2;
...@@ -138,10 +135,7 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type, ...@@ -138,10 +135,7 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
key_ref_put(keyring_ref); key_ref_put(keyring_ref);
error3: error3:
if (!vm) kvfree(payload);
kfree(payload);
else
vfree(payload);
error2: error2:
kfree(description); kfree(description);
error: error:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册