Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] pvrusb2: Use kcalloc instead of kzalloc to allocate array

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: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Thomas Meyer and committed by
Mauro Carvalho Chehab
e79c70e6 56a8b9f1

+3 -2
+3 -2
drivers/media/video/pvrusb2/pvrusb2-hdw.c
··· 2546 2546 } 2547 2547 2548 2548 /* Define and configure additional controls from cx2341x module. */ 2549 - hdw->mpeg_ctrl_info = kzalloc( 2550 - sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT, GFP_KERNEL); 2549 + hdw->mpeg_ctrl_info = kcalloc(MPEGDEF_COUNT, 2550 + sizeof(*(hdw->mpeg_ctrl_info)), 2551 + GFP_KERNEL); 2551 2552 if (!hdw->mpeg_ctrl_info) goto fail; 2552 2553 for (idx = 0; idx < MPEGDEF_COUNT; idx++) { 2553 2554 cptr = hdw->controls + idx + CTRLDEF_COUNT;