Using a helper shrinks the code and separating the user and kernel slabs is more secure.
Signed-off-by: Tvrtko Ursulin <[email protected]> Cc: Fei Yu <[email protected]> Cc: Christian König <[email protected]> --- drivers/gpu/drm/drm_syncobj.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index 6cc654641183..663d6cb8dbf8 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -1252,15 +1252,10 @@ static int drm_syncobj_array_find(struct drm_file *file_private, if (count_handles > DRM_SYNCOBJ_MAX_HANDLES) return -EINVAL; - handles = kvmalloc_objs(*handles, count_handles); - if (handles == NULL) - return -ENOMEM; - - if (copy_from_user(handles, user_handles, - sizeof(uint32_t) * count_handles)) { - ret = -EFAULT; - goto err_free_handles; - } + handles = vmemdup_array_user(user_handles, count_handles, + sizeof(*handles)); + if (IS_ERR(handles)) + return PTR_ERR(handles); syncobjs = kvmalloc_objs(*syncobjs, count_handles); if (syncobjs == NULL) { -- 2.56.0
