Commit 2baddf26 authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Greg Kroah-Hartman

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: default avatarDafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f1345b2f
...@@ -648,12 +648,10 @@ static int lst_test_add_ioctl(struct lstio_test_args *args) ...@@ -648,12 +648,10 @@ static int lst_test_add_ioctl(struct lstio_test_args *args)
return -EINVAL; return -EINVAL;
if (args->lstio_tes_param) { if (args->lstio_tes_param) {
param = kmalloc(args->lstio_tes_param_len, GFP_KERNEL); param = memdup_user(args->lstio_tes_param,
if (!param) args->lstio_tes_param_len);
goto out; if (IS_ERR(param)) {
if (copy_from_user(param, args->lstio_tes_param, rc = PTR_ERR(param);
args->lstio_tes_param_len)) {
rc = -EFAULT;
goto out; goto out;
} }
} }
......
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