All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: Switch over to memdup_user()
@ 2023-06-14  2:04 ` Jiapeng Chong
  0 siblings, 0 replies; 10+ messages in thread
From: Jiapeng Chong @ 2023-06-14  2:04 UTC (permalink / raw)
  To: Felix.Kuehling
  Cc: Jiapeng Chong, Xinhui.Pan, Abaci Robot, linux-kernel, amd-gfx,
	dri-devel, daniel, alexander.deucher, airlied, christian.koenig

Use memdup_user() rather than duplicating its implementation. This is a
little bit restricted to reduce false positives.

./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2813:13-20: WARNING opportunity for memdup_user.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5523
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index d6b15493fffd..637962d4083c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -2810,12 +2810,9 @@ static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array
 	if (!usr_queue_id_array)
 		return NULL;
 
-	queue_ids = kzalloc(array_size, GFP_KERNEL);
-	if (!queue_ids)
-		return ERR_PTR(-ENOMEM);
-
-	if (copy_from_user(queue_ids, usr_queue_id_array, array_size))
-		return ERR_PTR(-EFAULT);
+	queue_ids = memdup_user(usr_queue_id_array, array_size);
+	if (IS_ERR(queue_ids))
+		return PTR_ERR(queue_ids);
 
 	return queue_ids;
 }
-- 
2.20.1.7.g153144c


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-06-15  6:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-14  2:04 [PATCH] drm/amdkfd: Switch over to memdup_user() Jiapeng Chong
2023-06-14  2:04 ` Jiapeng Chong
2023-06-14  2:04 ` Jiapeng Chong
2023-06-14 12:21 ` kernel test robot
2023-06-14 12:21   ` kernel test robot
2023-06-14 15:11 ` Felix Kuehling
2023-06-14 15:11   ` Felix Kuehling
2023-06-14 15:11   ` Felix Kuehling
2023-06-15  6:32 ` kernel test robot
2023-06-15  6:32   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.