nouveau/svm: Use kvcalloc() instead of kvzalloc()
Subsystems (3)
PATCH 1/1 nouveau/svm: Use kvcalloc() instead of kvzalloc()
Use 2-factor argument form kvcalloc() instead of kvzalloc().
--- drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_svm.c +1 -1
@@ -992,7 +992,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)if (ret)return ret; - buffer->fault =kvzalloc (sizeof (*buffer->fault) * buffer->entries,GFP_KERNEL ); + buffer->fault =kvcalloc (sizeof (*buffer->fault), buffer->entries,GFP_KERNEL );if (!buffer->fault)return -ENOMEM ;
Signature · 1 line
2.27.0
Lack of documentation inside Linux here is a bit annoying, but do I understand it correctly, that the main (and probably only) difference is that kvcalloc checks whether the multiplication overflows and returns NULL in this case?
Quoted 25 lines · Gustavo A. R. Silva
Use 2-factor argument form
kvcalloc()instead ofkvzalloc().--- drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/nouveau/nouveau_svm.c +1
-2@@ -992,7 +992,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)if (ret)return ret; - buffer->fault =kvzalloc (sizeof (*buffer->fault) * buffer->entries,GFP_KERNEL ); + buffer->fault =kvcalloc (sizeof (*buffer->fault), buffer->entries,GFP_KERNEL );if (!buffer->fault)return -ENOMEM ; --2.27.0
Kees Cook
Reviewed-byQuoted 4 lines · Karol Herbst
Lack of documentation inside Linux here is a bit annoying, but do I understand it correctly, that the main (and probably only) difference is that kvcalloc checks whether the multiplication overflows and returns NULL in this case?
That's correct. :)
Quoted 7 lines
Quoted 5 lines · Gustavo A. R. Silva
Use 2-factor argument form
kvcalloc()instead ofkvzalloc().
Quoted 21 lines
Quoted 20 lines
--- drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/nouveau/nouveau_svm.c +1
-2@@ -992,7 +992,7 @@ nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)if (ret)return ret; - buffer->fault =kvzalloc (sizeof (*buffer->fault) * buffer->entries,GFP_KERNEL ); + buffer->fault =kvcalloc (sizeof (*buffer->fault), buffer->entries,GFP_KERNEL );if (!buffer->fault)return -ENOMEM ; --2.27.0
Signature · 1 line
Kees Cook
Quoted 11 lines · Kees Cook
Quoted 4 lines · Karol Herbst
Lack of documentation inside Linux here is a bit annoying, but do I understand it correctly, that the main (and probably only) difference is that kvcalloc checks whether the multiplication overflows and returns NULL in this case?
That's correct. :)
Quoted 3 lines
Quoted 1 line · Gustavo A. R. Silva
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Use 2-factor argument form
kvcalloc()instead ofkvzalloc().Reviewed-by Kees Cook <[email protected]>
I'll take this in my -next tree.
Thanks
--
Gustavo