2020-11-18 02:55:02

by 赵军奎

[permalink] [raw]
Subject: [PATCH] amdgpu/amdgpu_ids: fix kmalloc_array not uses number as first arg

Fix check_patch.pl warning:
kmalloc_array uses number as first arg, sizeof is generally wrong.
+fences = kmalloc_array(sizeof(void *), id_mgr->num_ids,
GFP_KERNEL);

Signed-off-by: Bernard Zhao <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
index 6e9a9e5dbea0..f2bd4b0e06f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
@@ -208,7 +208,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
if (ring->vmid_wait && !dma_fence_is_signaled(ring->vmid_wait))
return amdgpu_sync_fence(sync, ring->vmid_wait);

- fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
+ fences = kmalloc_array(id_mgr->num_ids, sizeof(void *), GFP_KERNEL);
if (!fences)
return -ENOMEM;

--
2.29.0


2020-11-18 08:19:38

by Christian König

[permalink] [raw]
Subject: Re: [PATCH] amdgpu/amdgpu_ids: fix kmalloc_array not uses number as first arg

Am 18.11.20 um 03:42 schrieb Bernard Zhao:
> Fix check_patch.pl warning:
> kmalloc_array uses number as first arg, sizeof is generally wrong.
> +fences = kmalloc_array(sizeof(void *), id_mgr->num_ids,
> GFP_KERNEL);
>
> Signed-off-by: Bernard Zhao <[email protected]>

Reviewed-by: Christian König <[email protected]>

> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> index 6e9a9e5dbea0..f2bd4b0e06f6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> @@ -208,7 +208,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
> if (ring->vmid_wait && !dma_fence_is_signaled(ring->vmid_wait))
> return amdgpu_sync_fence(sync, ring->vmid_wait);
>
> - fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
> + fences = kmalloc_array(id_mgr->num_ids, sizeof(void *), GFP_KERNEL);
> if (!fences)
> return -ENOMEM;
>

2020-11-19 21:59:05

by Alex Deucher

[permalink] [raw]
Subject: Re: [PATCH] amdgpu/amdgpu_ids: fix kmalloc_array not uses number as first arg

Applied. Thanks!

Alex

On Wed, Nov 18, 2020 at 3:17 AM Christian König
<[email protected]> wrote:
>
> Am 18.11.20 um 03:42 schrieb Bernard Zhao:
> > Fix check_patch.pl warning:
> > kmalloc_array uses number as first arg, sizeof is generally wrong.
> > +fences = kmalloc_array(sizeof(void *), id_mgr->num_ids,
> > GFP_KERNEL);
> >
> > Signed-off-by: Bernard Zhao <[email protected]>
>
> Reviewed-by: Christian König <[email protected]>
>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> > index 6e9a9e5dbea0..f2bd4b0e06f6 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> > @@ -208,7 +208,7 @@ static int amdgpu_vmid_grab_idle(struct amdgpu_vm *vm,
> > if (ring->vmid_wait && !dma_fence_is_signaled(ring->vmid_wait))
> > return amdgpu_sync_fence(sync, ring->vmid_wait);
> >
> > - fences = kmalloc_array(sizeof(void *), id_mgr->num_ids, GFP_KERNEL);
> > + fences = kmalloc_array(id_mgr->num_ids, sizeof(void *), GFP_KERNEL);
> > if (!fences)
> > return -ENOMEM;
> >
>
> _______________________________________________
> amd-gfx mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx