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

Configure Feed

Select the types of activity you want to include in your feed.

drm/imagination: Use memdup_user() helper to simplify code

Switching to memdup_user(), which combines kmalloc() and copy_from_user(),
and it can simplfy code.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240831102930.97502-1-ruanjinjie@huawei.com
Signed-off-by: Matt Coster <matt.coster@imgtec.com>

authored by

Jinjie Ruan and committed by
Matt Coster
3742c209 eb4accc5

+3 -10
+3 -10
drivers/gpu/drm/imagination/pvr_job.c
··· 90 90 void *stream; 91 91 int err; 92 92 93 - stream = kzalloc(stream_len, GFP_KERNEL); 94 - if (!stream) 95 - return -ENOMEM; 96 - 97 - if (copy_from_user(stream, u64_to_user_ptr(stream_userptr), stream_len)) { 98 - err = -EFAULT; 99 - goto err_free_stream; 100 - } 93 + stream = memdup_user(u64_to_user_ptr(stream_userptr), stream_len); 94 + if (IS_ERR(stream)) 95 + return PTR_ERR(stream); 101 96 102 97 err = pvr_job_process_stream(pvr_dev, stream_def, stream, stream_len, job); 103 98 104 - err_free_stream: 105 99 kfree(stream); 106 - 107 100 return err; 108 101 } 109 102