* [PATCH] [media] uvcvideo: Use kcalloc instead of kzalloc to allocate array
@ 2011-11-29 21:08 Thomas Meyer
2011-12-11 23:41 ` Laurent Pinchart
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Meyer @ 2011-11-29 21:08 UTC (permalink / raw)
To: laurent.pinchart, mchehab, linux-media, linux-kernel
The advantage of kcalloc is, that will prevent integer overflows which could
result from the multiplication of number of elements and size and it is also
a bit nicer to read.
The semantic patch that makes this change is available
in https://lkml.org/lkml/2011/11/25/107
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
diff -u -p a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
--- a/drivers/media/video/uvc/uvc_ctrl.c 2011-11-28 19:36:47.613437745 +0100
+++ b/drivers/media/video/uvc/uvc_ctrl.c 2011-11-28 19:58:26.309317018 +0100
@@ -1861,7 +1861,7 @@ int uvc_ctrl_init_device(struct uvc_devi
if (ncontrols == 0)
continue;
- entity->controls = kzalloc(ncontrols * sizeof(*ctrl),
+ entity->controls = kcalloc(ncontrols, sizeof(*ctrl),
GFP_KERNEL);
if (entity->controls == NULL)
return -ENOMEM;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [media] uvcvideo: Use kcalloc instead of kzalloc to allocate array
2011-11-29 21:08 [PATCH] [media] uvcvideo: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
@ 2011-12-11 23:41 ` Laurent Pinchart
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2011-12-11 23:41 UTC (permalink / raw)
To: Thomas Meyer; +Cc: mchehab, linux-media, linux-kernel
Hi Thomas,
Thanks for the patch.
On Tuesday 29 November 2011 22:08:00 Thomas Meyer wrote:
> The advantage of kcalloc is, that will prevent integer overflows which
> could result from the multiplication of number of elements and size and it
> is also a bit nicer to read.
>
> The semantic patch that makes this change is available
> in https://lkml.org/lkml/2011/11/25/107
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Should I take the patch in my tree, or do you plan to push several similar
patches directly in one go ?
> ---
>
> diff -u -p a/drivers/media/video/uvc/uvc_ctrl.c
> b/drivers/media/video/uvc/uvc_ctrl.c ---
> a/drivers/media/video/uvc/uvc_ctrl.c 2011-11-28 19:36:47.613437745 +0100
> +++ b/drivers/media/video/uvc/uvc_ctrl.c 2011-11-28 19:58:26.309317018
> +0100 @@ -1861,7 +1861,7 @@ int uvc_ctrl_init_device(struct uvc_devi
> if (ncontrols == 0)
> continue;
>
> - entity->controls = kzalloc(ncontrols * sizeof(*ctrl),
> + entity->controls = kcalloc(ncontrols, sizeof(*ctrl),
> GFP_KERNEL);
> if (entity->controls == NULL)
> return -ENOMEM;
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-11 23:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-29 21:08 [PATCH] [media] uvcvideo: Use kcalloc instead of kzalloc to allocate array Thomas Meyer
2011-12-11 23:41 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox