lkml.org 
[lkml]   [2017]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] KEYS: use memdup_user
Date
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.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
\
 
 \ /
  Last update: 2017-05-13 05:16    [W:0.078 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site