Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965629AbcJXU7m (ORCPT ); Mon, 24 Oct 2016 16:59:42 -0400 Received: from mout.web.de ([212.227.17.11]:51506 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941144AbcJXU7i (ORCPT ); Mon, 24 Oct 2016 16:59:38 -0400 Subject: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() To: linux-media@vger.kernel.org, Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , =?UTF-8?Q?Rafael_Louren=c3=a7o_de_Lima_Chehab?= , Shuah Khan , Wolfram Sang References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <68ad1aaa-c029-04b9-805a-e859f6c2d2d5@users.sourceforge.net> Date: Mon, 24 Oct 2016 22:59:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:s4ciQFyGZTZmLgqBdBYXYfGqw1Y+zZLLfxhJTWNwCnDaG3WQxBk RMz3IBq26cuPp9JAgRu2QdQP0ZyANAE/ACrRev9ib8HjftMgzhCJxGfSj1FvvU+xbV4w/WL dtzb4nsBtnu9rq+TKgqA26YDZJVZ3OJmqgzq8dCcGX/Ho+mJX0ymo2vaxjx7O1UQSkhtzUu GA3mV4LMhgYxLPNyqI0aQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:z7nvuVEWtfU=:2htm6FHpGhQw31XBJXaKql IyY/ATZIiuKeblcTzJVSU/Cm2PEGcRtWKnRfxkZncJWWle2AYEZ48/fcw+0FQHfMUvelHrRjP UU1nFWma8P5Uhv1N1JarXoLtK13HCG7wUXrHuJ/CHMG/1ZtjyuNDf+2izGMk8T0Zc9vGAknUp nO3Jku9y2S+p6kVJlzaJxKpVfl3UcruOXRvDx2n4uVcCMe+rfWAmn6lSCBZAUYl4Bsk9V7ZZK 9jdnI+EKBGyYlqJeN3qSlxNRfzVyzAb/33Lb+MGtgO9DMCprlK+Tq/u9bzlqwUKlaE5Rgrews VNkj66OH6g/Tyi1wpCAsBT2rJczc7uffQTIHqz2dLT/2CyigIWoTlls4aPqeEUrniIgWjS1av yK5e9YPXBUQlydI+zXm3wCFSP2fcRa1t0xA1XpiAa6exyLiOyzoGkGBYxK5Unbnpa8e9U3aFT qBdyh+0iSMOt2IyGrIFlbevPzGMd1bY3dD1TSleCSx4fUPnCrqNyl+MnX0nYyjIZzLwEBTqH6 DPl/frWaZG+KFB9MofZMy2p9I7JjFRhk9tlXePlQ505dkIPnXycpMyyYeVF+GKg8GQWyClycp +Lz/gNt/ug5+aTm9vJl4oUOh3n3fWbKjoZgglA5qah/EN/XRCVT+QprljAVp5xdBvLIisOtWa M96SqaHXiiImMuNaIIkeTJuWL4I0Hl9pEv1AE8aDMhC3u+gdn9znMlCn05+P7ARS2E56jDfH8 87aoCI/3YCNsM7e8xBae9OXBs4xRG28LqAWVtwe5aQKSvZWQEbTGXXGg5HggHkQewIbrCBLvC F/TZau2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1719 Lines: 47 From: Markus Elfring Date: Mon, 24 Oct 2016 22:08:47 +0200 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of data types by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/media/usb/au0828/au0828-video.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 85dd9a8..85b13c1 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, dev->isoc_ctl.isoc_copy = isoc_copy; dev->isoc_ctl.num_bufs = num_bufs; - - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); + dev->isoc_ctl.urb = kcalloc(num_bufs, + sizeof(*dev->isoc_ctl.urb), + GFP_KERNEL); if (!dev->isoc_ctl.urb) { au0828_isocdbg("cannot alloc memory for usb buffers\n"); return -ENOMEM; } - dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, - GFP_KERNEL); + dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, + sizeof(*dev->isoc_ctl + .transfer_buffer), + GFP_KERNEL); if (!dev->isoc_ctl.transfer_buffer) { au0828_isocdbg("cannot allocate memory for usb transfer\n"); kfree(dev->isoc_ctl.urb); -- 2.10.1