@@ -66,29 +66,14 @@ static int
process_static_context_state(struct pvr_device *pvr_dev, const struct pvr_stream_cmd_defs *cmd_defs,
u64 stream_user_ptr, u32 stream_size, void *dest)
{
- void *stream;
int err;
+ void *stream = memdup_user(u64_to_user_ptr(stream_user_ptr), stream_size);
- stream = kzalloc(stream_size, GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-
- if (copy_from_user(stream, u64_to_user_ptr(stream_user_ptr), stream_size)) {
- err = -EFAULT;
- goto err_free;
- }
+ if (IS_ERR(stream))
+ return PTR_ERR(stream);
err = pvr_stream_process(pvr_dev, cmd_defs, stream, stream_size, dest);
- if (err)
- goto err_free;
-
kfree(stream);
-
- return 0;
-
-err_free:
- kfree(stream);
-
return err;
}
@@ -87,23 +87,14 @@ static int pvr_fw_cmd_init(struct pvr_device *pvr_dev, struct pvr_job *job,
const struct pvr_stream_cmd_defs *stream_def,
u64 stream_userptr, u32 stream_len)
{
- void *stream;
int err;
+ void *stream = memdup_user(u64_to_user_ptr(stream_userptr), stream_len);
- stream = kzalloc(stream_len, GFP_KERNEL);
- if (!stream)
- return -ENOMEM;
-
- if (copy_from_user(stream, u64_to_user_ptr(stream_userptr), stream_len)) {
- err = -EFAULT;
- goto err_free_stream;
- }
+ if (IS_ERR(stream))
+ return PTR_ERR(stream);
err = pvr_job_process_stream(pvr_dev, stream_def, stream, stream_len, job);
-
-err_free_stream:
kfree(stream);
-
return err;
}