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

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

Return early if an error occurs and remove the obsolete 'out' label.

No functional changes intended.

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
6156c101 d4b6274c

+3 -9
+3 -9
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
··· 521 521 cu_mask_size = sizeof(uint32_t) * (max_num_cus/32); 522 522 } 523 523 524 - minfo.cu_mask.ptr = kzalloc(cu_mask_size, GFP_KERNEL); 525 - if (!minfo.cu_mask.ptr) 526 - return -ENOMEM; 527 - 528 - retval = copy_from_user(minfo.cu_mask.ptr, cu_mask_ptr, cu_mask_size); 529 - if (retval) { 524 + minfo.cu_mask.ptr = memdup_user(cu_mask_ptr, cu_mask_size); 525 + if (IS_ERR(minfo.cu_mask.ptr)) { 530 526 pr_debug("Could not copy CU mask from userspace"); 531 - retval = -EFAULT; 532 - goto out; 527 + return PTR_ERR(minfo.cu_mask.ptr); 533 528 } 534 529 535 530 mutex_lock(&p->mutex); ··· 533 538 534 539 mutex_unlock(&p->mutex); 535 540 536 - out: 537 541 kfree(minfo.cu_mask.ptr); 538 542 return retval; 539 543 }