From: Al Viro Date: Sat, 13 May 2017 22:39:01 +0000 (-0400) Subject: kimage_file_prepare_segments(): don't open-code memdup_user() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a9bd8dfa539493db265e46a496c1a89279ab31d1;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git kimage_file_prepare_segments(): don't open-code memdup_user() Signed-off-by: Al Viro --- diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index b118735fea9d..766e7e4d3ad9 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -162,16 +162,10 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, } if (cmdline_len) { - image->cmdline_buf = kzalloc(cmdline_len, GFP_KERNEL); - if (!image->cmdline_buf) { - ret = -ENOMEM; - goto out; - } - - ret = copy_from_user(image->cmdline_buf, cmdline_ptr, - cmdline_len); - if (ret) { - ret = -EFAULT; + image->cmdline_buf = memdup_user(cmdline_ptr, cmdline_len); + if (IS_ERR(image->cmdline_buf)) { + ret = PTR_ERR(image->cmdline_buf); + image->cmdline_buf = NULL; goto out; }