From patchwork Mon Oct 24 20:59:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9393283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7752660231 for ; Mon, 24 Oct 2016 21:00:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 676AF2908E for ; Mon, 24 Oct 2016 21:00:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BCA2290A3; Mon, 24 Oct 2016 21:00:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECAFF2908E for ; Mon, 24 Oct 2016 20:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965559AbcJXU7j (ORCPT ); Mon, 24 Oct 2016 16:59:39 -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 Received: from [192.168.1.2] ([77.182.95.108]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LvSLn-1cy8Lt0lwR-010cTe; Mon, 24 Oct 2016 22:59:26 +0200 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: 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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);