mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/6] KEYS: use kvfree() in add_key
@ 2015-10-21 14:26 David Howells
  2015-10-21 14:26 ` [PATCH 2/6] certs: add .gitignore to stop git nagging about x509_certificate_list David Howells
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: David Howells @ 2015-10-21 14:26 UTC (permalink / raw)
  To: keyrings; +Cc: dhowells, Geliang Tang, linux-security-module, linux-kernel

From: Geliang Tang <geliangtang@163.com>

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 <geliangtang@163.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 security/keys/keyctl.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 0b9ec78a7a7a..6110fa498494 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -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)
@@ -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;
@@ -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:


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-21 14:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21 14:26 [PATCH 1/6] KEYS: use kvfree() in add_key David Howells
2015-10-21 14:26 ` [PATCH 2/6] certs: add .gitignore to stop git nagging about x509_certificate_list David Howells
2015-10-21 14:27 ` [PATCH 3/6] keys: Be more consistent in selection of union members used David Howells
2015-10-21 14:27 ` [PATCH 4/6] KEYS: Provide a script to extract the sys cert list from a vmlinux file David Howells
2015-10-21 14:27 ` [PATCH 5/6] KEYS: Provide a script to extract a module signature David Howells
2015-10-21 14:27 ` [PATCH 6/6] KEYS: Merge the type-specific data with the payload data David Howells
2015-10-21 14:29 ` [PATCH 1/6] KEYS: use kvfree() in add_key David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®