From patchwork Wed Oct 12 15:03:19 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: 9373399 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 2AA7660772 for ; Wed, 12 Oct 2016 15:07:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D26C29D9D for ; Wed, 12 Oct 2016 15:07:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1157529DC7; Wed, 12 Oct 2016 15:07:57 +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 DB95729D9D for ; Wed, 12 Oct 2016 15:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933872AbcJLPFM (ORCPT ); Wed, 12 Oct 2016 11:05:12 -0400 Received: from mout.web.de ([212.227.15.4]:61060 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933324AbcJLPEC (ORCPT ); Wed, 12 Oct 2016 11:04:02 -0400 Received: from [192.168.1.2] ([78.49.9.22]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0M4Um4-1avuHE1Ba0-00ygLl; Wed, 12 Oct 2016 17:03:20 +0200 Subject: [PATCH 25/34] [media] DaVinci-VPIF-Capture: Use kcalloc() in vpif_probe() To: linux-media@vger.kernel.org, Hans Verkuil , "Lad, Prabhakar" , Mauro Carvalho Chehab References: Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <506f65c8-645f-d408-433a-d716da0ab3bc@users.sourceforge.net> Date: Wed, 12 Oct 2016 17:03:19 +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:AQKWjBGjPvt9VB+vFBF5Ps5Pv+0sR3NsCIlWqdFFTzoQfM/9ctN zr9BJnBfq7ray69vmfm7qjlPF8piNg6l0bY+BaOvI+2Yx1lVWrRl9YE/s5Y5vVqiwiyHZVV 3pNgIVfMCPUG344INf4hLXvmWphCoXck/N/HbtnLpfg/z7mozWNLY5iLraIJKiM+vS+0kiU 6uTCpbtszq8FbRYSx+Kaw== X-UI-Out-Filterresults: notjunk:1; V01:K0:JfTvSj59Ahs=:M+LGaAeC4EWOsvg81+doWi TL0EQovE1QpgB1v4tm1dcaEe3Ckf5/iI1sj8AVkdLQzWAfAP6b71fYTSldBLtLjl+yl/wmUAC l/K+7602ZsF99RmACwCO36r9Vig5d4zip/tfak5sMIVBlbEIUBWzx7C/pF3AkNQfE5UD3qs2b 4EIb9+a+CmCHrlH+nDGPpdTr0lnSgD2jPBITHOxfJckezpiBJX6NCm+J+fMEQlMQZ+ftXeMIV 6cpD0FAyiBoXML9+H0619CobdEOCC0lFIWpHq/DUGbc1cMyiwCjNcSGgwCUgiYRNcgLvo4MNa T6zSjOyEqm7+x99JgMHbb1oYlhpzYErFM03y6XMsjYwMBDTPbbP+3SSURLgfAiie0BHnFyZxF lyat2lWM4cXDzevTAcUNQtS4j3AA8nwBSf8AqM/Ag9WmB5hzdCTpX9LiHuiHFTuXv1W01lavc 2jhbaVXRHAUClIx5o/2vz8quXhKuMdkP9GjsGRX5Vu9uLDJ3X8IZgJF9WsPLsISP3SL/57U// riPR59wxYJKfU3SBnZSRaEIx0DeRqNuRTeO02M1Ll+CzxQVCvq/dzdTNXaUl0rq9vWsF9MBGT jdd37Pl+4EddSchhCqGPSEt33yziZo2fXt8w1whqN47sStq33HUP0Br2EqdnFfzEgnctZ97c4 7s/UGhNV/7Sy198IKsjLTEfoJhFTxjNB5ju/pD9QsAtGI6hMLPbQDw07bQ3qoXhbeMHdOeUTu wDitng+f8mVT+gQKxdz2scNQkgBNhYVm46BxE1eXml3zNsJCMcSKPwgPp7fQdo0pBrd68BZNu iZjNxol 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: Wed, 12 Oct 2016 15:15:34 +0200 * A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/media/platform/davinci/vpif_capture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 5104cc0..fb9e850 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -1464,8 +1464,7 @@ static __init int vpif_probe(struct platform_device *pdev) vpif_obj.config = pdev->dev.platform_data; subdev_count = vpif_obj.config->subdev_count; - vpif_obj.sd = kzalloc(sizeof(struct v4l2_subdev *) * subdev_count, - GFP_KERNEL); + vpif_obj.sd = kcalloc(subdev_count, sizeof(*vpif_obj.sd), GFP_KERNEL); if (vpif_obj.sd == NULL) { vpif_err("unable to allocate memory for subdevice pointers\n"); err = -ENOMEM;