* [PATCH v2] drm/amdkfd: Use memdup_user() rather than duplicating its implementation
@ 2023-08-09 5:30 ` Atul Raut
0 siblings, 0 replies; 4+ messages in thread
From: Atul Raut @ 2023-08-09 5:30 UTC (permalink / raw)
To: Felix.Kuehling; +Cc: linux-kernel-mentees, amd-gfx
To prevent its redundant implementation and streamline
code, use memdup_user.
This fixes warnings reported by Coccinelle:
./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2811:13-20: WARNING opportunity for memdup_user
Signed-off-by: Atul Raut <rauji.raut@gmail.com>
---
v1 -> v2
caller checks for errors, hence removed
---
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 10 +---------
1 file changed, 1 insertion(+), 9 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 2df153828ff4..df9b618756e6 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -2803,19 +2803,11 @@ static void copy_context_work_handler (struct work_struct *work)
static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array)
{
size_t array_size = num_queues * sizeof(uint32_t);
- uint32_t *queue_ids = NULL;
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);
-
- return queue_ids;
+ return memdup_user(usr_queue_id_array, array_size);
}
int resume_queues(struct kfd_process *p,
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2] drm/amdkfd: Use memdup_user() rather than duplicating its implementation
@ 2023-08-09 5:30 ` Atul Raut
0 siblings, 0 replies; 4+ messages in thread
From: Atul Raut @ 2023-08-09 5:30 UTC (permalink / raw)
To: Felix.Kuehling; +Cc: linux-kernel-mentees, amd-gfx
To prevent its redundant implementation and streamline
code, use memdup_user.
This fixes warnings reported by Coccinelle:
./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2811:13-20: WARNING opportunity for memdup_user
Signed-off-by: Atul Raut <rauji.raut@gmail.com>
---
v1 -> v2
caller checks for errors, hence removed
---
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 10 +---------
1 file changed, 1 insertion(+), 9 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 2df153828ff4..df9b618756e6 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -2803,19 +2803,11 @@ static void copy_context_work_handler (struct work_struct *work)
static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array)
{
size_t array_size = num_queues * sizeof(uint32_t);
- uint32_t *queue_ids = NULL;
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);
-
- return queue_ids;
+ return memdup_user(usr_queue_id_array, array_size);
}
int resume_queues(struct kfd_process *p,
--
2.34.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] drm/amdkfd: Use memdup_user() rather than duplicating its implementation
2023-08-09 5:30 ` Atul Raut
@ 2023-08-09 19:12 ` Felix Kuehling via Linux-kernel-mentees
-1 siblings, 0 replies; 4+ messages in thread
From: Felix Kuehling @ 2023-08-09 19:12 UTC (permalink / raw)
To: Atul Raut; +Cc: linux-kernel-mentees, amd-gfx
On 2023-08-09 01:30, Atul Raut wrote:
> To prevent its redundant implementation and streamline
> code, use memdup_user.
>
> This fixes warnings reported by Coccinelle:
> ./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2811:13-20: WARNING opportunity for memdup_user
>
> Signed-off-by: Atul Raut <rauji.raut@gmail.com>
The patch is
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
I'm applying it to amd-staging-drm-next.
Regards,
Felix
> ---
> v1 -> v2
> caller checks for errors, hence removed
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 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 2df153828ff4..df9b618756e6 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -2803,19 +2803,11 @@ static void copy_context_work_handler (struct work_struct *work)
> static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array)
> {
> size_t array_size = num_queues * sizeof(uint32_t);
> - uint32_t *queue_ids = NULL;
>
> 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);
> -
> - return queue_ids;
> + return memdup_user(usr_queue_id_array, array_size);
> }
>
> int resume_queues(struct kfd_process *p,
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] drm/amdkfd: Use memdup_user() rather than duplicating its implementation
@ 2023-08-09 19:12 ` Felix Kuehling via Linux-kernel-mentees
0 siblings, 0 replies; 4+ messages in thread
From: Felix Kuehling via Linux-kernel-mentees @ 2023-08-09 19:12 UTC (permalink / raw)
To: Atul Raut; +Cc: linux-kernel-mentees, amd-gfx
On 2023-08-09 01:30, Atul Raut wrote:
> To prevent its redundant implementation and streamline
> code, use memdup_user.
>
> This fixes warnings reported by Coccinelle:
> ./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2811:13-20: WARNING opportunity for memdup_user
>
> Signed-off-by: Atul Raut <rauji.raut@gmail.com>
The patch is
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
I'm applying it to amd-staging-drm-next.
Regards,
Felix
> ---
> v1 -> v2
> caller checks for errors, hence removed
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 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 2df153828ff4..df9b618756e6 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -2803,19 +2803,11 @@ static void copy_context_work_handler (struct work_struct *work)
> static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array)
> {
> size_t array_size = num_queues * sizeof(uint32_t);
> - uint32_t *queue_ids = NULL;
>
> 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);
> -
> - return queue_ids;
> + return memdup_user(usr_queue_id_array, array_size);
> }
>
> int resume_queues(struct kfd_process *p,
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-09 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 5:30 [PATCH v2] drm/amdkfd: Use memdup_user() rather than duplicating its implementation Atul Raut
2023-08-09 5:30 ` Atul Raut
2023-08-09 19:12 ` Felix Kuehling
2023-08-09 19:12 ` Felix Kuehling via Linux-kernel-mentees
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.