From patchwork Wed Oct 12 14:51:10 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: 9373335 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 C733B60487 for ; Wed, 12 Oct 2016 14:51:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B927629E2D for ; Wed, 12 Oct 2016 14:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB15929E3C; Wed, 12 Oct 2016 14:51:35 +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 5335129E32 for ; Wed, 12 Oct 2016 14:51:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755068AbcJLOvW (ORCPT ); Wed, 12 Oct 2016 10:51:22 -0400 Received: from mout.web.de ([212.227.15.4]:62675 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754831AbcJLOvU (ORCPT ); Wed, 12 Oct 2016 10:51:20 -0400 Received: from [192.168.1.2] ([78.49.9.22]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0M6QBP-1awk443TIZ-00yPhU; Wed, 12 Oct 2016 16:51:11 +0200 Subject: [PATCH 13/34] [media] DaVinci-VPFE-Capture: Use kmalloc_array() in vpfe_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: <19376d4d-c7a9-1387-d054-bd1f5ae541e0@users.sourceforge.net> Date: Wed, 12 Oct 2016 16:51:10 +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:kzTcTlEamXUxlk951cWRTTYcZYhJ2BLZ+diTMjqLqJwwyl6hR4z SGWqFJudpEJc3Qxl963uc3n8OTNdIZjQ9RnM6cfxASVdie6mJjCokua99DE80VfP1Fr+7JR 9204lMZM4stSNX8eLtfZ9SBoVaPp7f74GaabyTMMJ8ZxCKCW9860CaC921j3gCPKzIqzzJs cqBewcDcL5Dlt803oV2jQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:Nw+ea3BTpaI=:QoP6kLibwFNAsec9rUJnYl lEvNuwgcVgIvqLTwfoUbkMeZN9130cp9zrRqou/LZPfiHSDtDvDX/lTONbsowk5QchdTZafBz Px7F6qO2qPxuL1fK5HeplaCcU3LnK2Wtyg1iQ1lSDbIv7QCOSWIHkfNG/+z2rM/K7IjvjMeYg Y5lVKIdv2DdJxT6fq6dkuAexgcOJqxr7c/mnUOzECn7TtwuS8k7k/MD4o44fbb9uaQJJ2bqcz 3NLB5vIQIsvTNpnLLAFKJiBEacUxtZoY3/jGHLLJNjZkxFxepBdTfsYb0PyloC8QmNC802TDF Pmjt9qFYLT/3e3DeOeTEltlJjaU5BWcsmymVqYgqhRfpNY8XW/+9aCQHDnppUiT9lb3Hs0Jbr EK16CIm0ppph8re/y3CMH07IIhGqPTPSjofWGhF+u5K5kpadtdydFsdL7Mx7mVkMC9uZk0tfO eRYmJrcyvnGY5gCH5KzGCNMTaw2XHcaF4xQgAQ7PllgRzPYH6rP/GfIwGjCbqLmq+ldUx99xt rzGtcheUW4wev2i1MJG3r1mZy5Qjva7vihJi5anqCISJmkBGQtJdm5kZOXGTmxt0QvCWhYbDp 4Xw+J86kyXm/9WAPt5TdzjEmN8XL1d4ipQ87z9FOl4rEsKvoMnDXgdDZc3rjDAUD/tP12xIRk nZf86AOSXxLOXhv0Y71GJYiCxY35kPydgcK8EDCOYwMNrwTqUmSN0BCu51uApUHeYlk/EzqPP hJFJXH+LdM5GWUpCKDkIIS2gnaHYHQU+a602KRqXWc3Qkvs7gSBIIOPaC5Eikvxpo4K80uTgk RZVO4+B 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 10:20:02 +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 "kmalloc_array". 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/vpfe_capture.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 6efb2f1..5c1b8cf 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -1940,8 +1940,9 @@ static int vpfe_probe(struct platform_device *pdev) video_set_drvdata(&vpfe_dev->video_dev, vpfe_dev); i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id); num_subdevs = vpfe_cfg->num_subdevs; - vpfe_dev->sd = kmalloc(sizeof(struct v4l2_subdev *) * num_subdevs, - GFP_KERNEL); + vpfe_dev->sd = kmalloc_array(num_subdevs, + sizeof(*vpfe_dev->sd), + GFP_KERNEL); if (NULL == vpfe_dev->sd) { v4l2_err(&vpfe_dev->v4l2_dev, "unable to allocate memory for subdevice pointers\n");