summaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lnet/selftest/conctl.c
diff options
context:
space:
mode:
authorDafna Hirschfeld <dafna3@gmail.com>2018-02-19 21:57:37 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-20 09:03:42 +0100
commit2baddf262e98762b36b0866065c21452fff1beda (patch)
treeb0e1af90e63f16e8034c54ce0ec4b1726c8ea14b /drivers/staging/lustre/lnet/selftest/conctl.c
parentf1345b2f21e6f827a6445a3ea873336e540458cd (diff)
downloadlinux-0-day-2baddf262e98762b36b0866065c21452fff1beda.tar.gz
linux-0-day-2baddf262e98762b36b0866065c21452fff1beda.tar.xz
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>
Diffstat (limited to 'drivers/staging/lustre/lnet/selftest/conctl.c')
-rw-r--r--drivers/staging/lustre/lnet/selftest/conctl.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c
index 34ba440b3c028..3c919a536e91b 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -648,12 +648,10 @@ static int lst_test_add_ioctl(struct lstio_test_args *args)
return -EINVAL;
if (args->lstio_tes_param) {
- param = kmalloc(args->lstio_tes_param_len, GFP_KERNEL);
- if (!param)
- goto out;
- if (copy_from_user(param, args->lstio_tes_param,
- args->lstio_tes_param_len)) {
- rc = -EFAULT;
+ param = memdup_user(args->lstio_tes_param,
+ args->lstio_tes_param_len);
+ if (IS_ERR(param)) {
+ rc = PTR_ERR(param);
goto out;
}
}