* [PATCH] nouveau/svm: fix kvcalloc() argument order
@ 2024-02-12 11:22 Arnd Bergmann
2024-02-12 15:17 ` Danilo Krummrich
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2024-02-12 11:22 UTC (permalink / raw)
To: Karol Herbst, Lyude Paul, Danilo Krummrich, David Airlie,
Daniel Vetter, Gustavo A. R. Silva, Kees Cook
Cc: Arnd Bergmann, Dave Airlie, Jani Nikula, dri-devel, nouveau,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The conversion to kvcalloc() mixed up the object size and count
arguments, causing a warning:
drivers/gpu/drm/nouveau/nouveau_svm.c: In function 'nouveau_svm_fault_buffer_ctor':
drivers/gpu/drm/nouveau/nouveau_svm.c:1010:40: error: 'kvcalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
1010 | buffer->fault = kvcalloc(sizeof(*buffer->fault), buffer->entries, GFP_KERNEL);
| ^
drivers/gpu/drm/nouveau/nouveau_svm.c:1010:40: note: earlier argument should specify number of elements, later size of each element
The behavior is still correct aside from the warning, but fixing it avoids
the warnings and can help the compiler track the individual objects better.
Fixes: 71e4bbca070e ("nouveau/svm: Use kvcalloc() instead of kvzalloc()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 4d1008915499..b4da82ddbb6b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -1007,7 +1007,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
if (ret)
return ret;
- buffer->fault = kvcalloc(sizeof(*buffer->fault), buffer->entries, GFP_KERNEL);
+ buffer->fault = kvcalloc(buffer->entries, sizeof(*buffer->fault), GFP_KERNEL);
if (!buffer->fault)
return -ENOMEM;
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] nouveau/svm: fix kvcalloc() argument order
2024-02-12 11:22 [PATCH] nouveau/svm: fix kvcalloc() argument order Arnd Bergmann
@ 2024-02-12 15:17 ` Danilo Krummrich
0 siblings, 0 replies; 2+ messages in thread
From: Danilo Krummrich @ 2024-02-12 15:17 UTC (permalink / raw)
To: Arnd Bergmann, Karol Herbst, Lyude Paul, David Airlie,
Daniel Vetter, Gustavo A. R. Silva, Kees Cook
Cc: Arnd Bergmann, Dave Airlie, Jani Nikula, dri-devel, nouveau,
linux-kernel
On 2/12/24 12:22, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The conversion to kvcalloc() mixed up the object size and count
> arguments, causing a warning:
>
> drivers/gpu/drm/nouveau/nouveau_svm.c: In function 'nouveau_svm_fault_buffer_ctor':
> drivers/gpu/drm/nouveau/nouveau_svm.c:1010:40: error: 'kvcalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
> 1010 | buffer->fault = kvcalloc(sizeof(*buffer->fault), buffer->entries, GFP_KERNEL);
> | ^
> drivers/gpu/drm/nouveau/nouveau_svm.c:1010:40: note: earlier argument should specify number of elements, later size of each element
>
> The behavior is still correct aside from the warning, but fixing it avoids
> the warnings and can help the compiler track the individual objects better.
>
> Fixes: 71e4bbca070e ("nouveau/svm: Use kvcalloc() instead of kvzalloc()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied to drm-misc-fixes, thanks!
> ---
> drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
> index 4d1008915499..b4da82ddbb6b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_svm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
> @@ -1007,7 +1007,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
> if (ret)
> return ret;
>
> - buffer->fault = kvcalloc(sizeof(*buffer->fault), buffer->entries, GFP_KERNEL);
> + buffer->fault = kvcalloc(buffer->entries, sizeof(*buffer->fault), GFP_KERNEL);
> if (!buffer->fault)
> return -ENOMEM;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-12 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-12 11:22 [PATCH] nouveau/svm: fix kvcalloc() argument order Arnd Bergmann
2024-02-12 15:17 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox