diff options
author | Geliang Tang <geliangtang@gmail.com> | 2017-06-02 09:52:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-06-05 11:50:42 -0400 |
commit | 5f72cad65cfaac5e40d0de8b7f48ee647af69cd5 (patch) | |
tree | 372d88d129d9bff7eba39bb5dfa5746c78bd7cda | |
parent | 2959c95d510cc45b246ba727eb8fdf8b601c6eec (diff) |
efi/efi_test: Use memdup_user() helper
Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Ivan 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.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | drivers/firmware/efi/test/efi_test.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c index 8cd578f62059..08129b7b80ab 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c | |||
@@ -71,18 +71,13 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src, | |||
71 | if (!access_ok(VERIFY_READ, src, 1)) | 71 | if (!access_ok(VERIFY_READ, src, 1)) |
72 | return -EFAULT; | 72 | return -EFAULT; |
73 | 73 | ||
74 | buf = kmalloc(len, GFP_KERNEL); | 74 | buf = memdup_user(src, len); |
75 | if (!buf) { | 75 | if (IS_ERR(buf)) { |
76 | *dst = NULL; | 76 | *dst = NULL; |
77 | return -ENOMEM; | 77 | return PTR_ERR(buf); |
78 | } | 78 | } |
79 | *dst = buf; | 79 | *dst = buf; |
80 | 80 | ||
81 | if (copy_from_user(*dst, src, len)) { | ||
82 | kfree(buf); | ||
83 | return -EFAULT; | ||
84 | } | ||
85 | |||
86 | return 0; | 81 | return 0; |
87 | } | 82 | } |
88 | 83 | ||