[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <908fa521decaf3703e172c3734c0d498741f3ddb.1494580404.git.geliangtang@gmail.com>
Date: Sat, 13 May 2017 11:15:57 +0800
From: Geliang Tang <geliangtang@...il.com>
To: David Howells <dhowells@...hat.com>,
James Morris <james.l.morris@...cle.com>,
"Serge E. Hallyn" <serge@...lyn.com>
Cc: Geliang Tang <geliangtang@...il.com>, keyrings@...r.kernel.org,
linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] KEYS: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@...il.com>
---
security/keys/keyctl.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index dd0da25..ce1574a 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -326,14 +326,11 @@ long keyctl_update_key(key_serial_t id,
/* pull the payload in if one was supplied */
payload = NULL;
if (_payload) {
- ret = -ENOMEM;
- payload = kmalloc(plen, GFP_KERNEL);
- if (!payload)
+ payload = memdup_user(_payload, plen);
+ if (IS_ERR(payload)) {
+ ret = PTR_ERR(payload);
goto error;
-
- ret = -EFAULT;
- if (copy_from_user(payload, _payload, plen) != 0)
- goto error2;
+ }
}
/* find the target key (which must be writable) */
--
2.9.3
Powered by blists - more mailing lists