Commit 5f72cad6 authored by Geliang Tang's avatar Geliang Tang Committed by Ingo Molnar

efi/efi_test: Use memdup_user() helper

Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: default avatarIvan Hu <ivan.hu@canonical.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-12-ard.biesheuvel@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 2959c95d
......@@ -71,18 +71,13 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
if (!access_ok(VERIFY_READ, src, 1))
return -EFAULT;
buf = kmalloc(len, GFP_KERNEL);
if (!buf) {
buf = memdup_user(src, len);
if (IS_ERR(buf)) {
*dst = NULL;
return -ENOMEM;
return PTR_ERR(buf);
}
*dst = buf;
if (copy_from_user(*dst, src, len)) {
kfree(buf);
return -EFAULT;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment