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/amdgpu: Replace kzalloc + copy_from_user with memdup_user

Replace kzalloc() followed by copy_from_user() with memdup_user() to
improve and simplify ta_if_load_debugfs_write() and
ta_if_invoke_debugfs_write().

No functional changes intended.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Thorsten Blum and committed by
Alex Deucher
99eeb835 6156c101

+6 -14
+6 -14
drivers/gpu/drm/amd/amdgpu/amdgpu_psp_ta.c
··· 171 171 172 172 copy_pos += sizeof(uint32_t); 173 173 174 - ta_bin = kzalloc(ta_bin_len, GFP_KERNEL); 175 - if (!ta_bin) 176 - return -ENOMEM; 177 - if (copy_from_user((void *)ta_bin, &buf[copy_pos], ta_bin_len)) { 178 - ret = -EFAULT; 179 - goto err_free_bin; 180 - } 174 + ta_bin = memdup_user(&buf[copy_pos], ta_bin_len); 175 + if (IS_ERR(ta_bin)) 176 + return PTR_ERR(ta_bin); 181 177 182 178 /* Set TA context and functions */ 183 179 set_ta_context_funcs(psp, ta_type, &context); ··· 323 327 return -EFAULT; 324 328 copy_pos += sizeof(uint32_t); 325 329 326 - shared_buf = kzalloc(shared_buf_len, GFP_KERNEL); 327 - if (!shared_buf) 328 - return -ENOMEM; 329 - if (copy_from_user((void *)shared_buf, &buf[copy_pos], shared_buf_len)) { 330 - ret = -EFAULT; 331 - goto err_free_shared_buf; 332 - } 330 + shared_buf = memdup_user(&buf[copy_pos], shared_buf_len); 331 + if (IS_ERR(shared_buf)) 332 + return PTR_ERR(shared_buf); 333 333 334 334 set_ta_context_funcs(psp, ta_type, &context); 335 335