Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: lustre: use memdup_user to allocate memory and copy from user

Replace a call to kmalloc and a call to copy_from_user with a
call to memdup_user to simplify the code.
Issue found with coccicheck.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dafna Hirschfeld and committed by
Greg Kroah-Hartman
2baddf26 f1345b2f

+4 -6
+4 -6
drivers/staging/lustre/lnet/selftest/conctl.c
··· 648 648 return -EINVAL; 649 649 650 650 if (args->lstio_tes_param) { 651 - param = kmalloc(args->lstio_tes_param_len, GFP_KERNEL); 652 - if (!param) 653 - goto out; 654 - if (copy_from_user(param, args->lstio_tes_param, 655 - args->lstio_tes_param_len)) { 656 - rc = -EFAULT; 651 + param = memdup_user(args->lstio_tes_param, 652 + args->lstio_tes_param_len); 653 + if (IS_ERR(param)) { 654 + rc = PTR_ERR(param); 657 655 goto out; 658 656 } 659 657 }