From patchwork Wed Oct 12 14:29:01 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: 9373273 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 3B80E60772 for ; Wed, 12 Oct 2016 14:29:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29D4D295D6 for ; Wed, 12 Oct 2016 14:29:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B0F6295DB; Wed, 12 Oct 2016 14:29:29 +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 AAEB6295D6 for ; Wed, 12 Oct 2016 14:29:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933237AbcJLO3Z (ORCPT ); Wed, 12 Oct 2016 10:29:25 -0400 Received: from mout.web.de ([212.227.15.14]:60100 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933302AbcJLO3X (ORCPT ); Wed, 12 Oct 2016 10:29:23 -0400 Received: from [192.168.1.2] ([78.49.9.22]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0MMEyj-1bmv4O0cV3-00802L; Wed, 12 Oct 2016 16:29:13 +0200 Subject: [PATCH 01/34] [media] DaVinci-VPBE: Use kmalloc_array() in vpbe_initialize() 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: Date: Wed, 12 Oct 2016 16:29:01 +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:0MBCVxz4vk5s1lL8O5A46FI/t/daKt2SLH7g5VPkrNAgfXngZAh YYbmeTzoExGI0bzLLN5Ca1SGpIPsQZKdpCLWVD7OsZP6IV5d5Bs2vYU5SibfeMbfMzZs4Ws j4kFB1JyPEoFUhcVUyhn+FDvCPxb++bB/VVfppt8356t8UGks3CquEAc2wwQy2LqEV+fQHH cdoaurv7bMOETPy4FALfA== X-UI-Out-Filterresults: notjunk:1; V01:K0:RQHGoPQ9cBY=:HbTn+h3jJQP1fG2sz5qqYa CpznHOMfwurLkIo3Bm+GYMAIjgVGmtf+PLfWX+pEsbNT6NuFMovZv9g6BontsTLb69b9eZFWs fuihzXP7iAfZXv++umg5WcBZAq/l9/jbVpnA8s7D7q68iK90nezF9dHKuLfYqiKpfZ66lOama y993O3pL7tjWwtj8bSBeHIGfL+XWatLW8NRV1hFslVSYYEB6NTQHGoAvBcMlasKRaCpvWf6ri 8wyJapFtvcHkBlkpm+E4JWzf/lLj133SAynyBJW6vzZrUrPTib40uNtf+32MnvC/rXWSjyG0u wmwdjmIZDjH0rnWKXxA3l2WyiCTfl5IZh57UfRfG1FvZ+t5DFeeOp8Ulqc+S9X0ice/dBN6YY 2zytaIqK5I8RbnUhtEEgZSHITnvCndyaV+CordI4e7TQIAZ6oSA4n6wRLPNzRvoWkYOfIPg6I +XTfMMuqw26WGS5eyyginaY/XkHKiA1gbsmNobJ1qPsQKKwVAqV75wnGvDiQyldu8k2L3yiJH ycM54lOzRPwaDW4HZO8xu4+EZ4OJWkvb+LUmxp/ZVpSNDgX9UrF+mQt+KVkSDw4uyX+C9Zqet +xFjHzLh2UF2JM4iX6m3LP7sK8dlyjWxz9NuNjXvBfmzb79/bDfyKlBuKnvRW++/F6JlX/ZTD a6UbTWQkoIAK80xb4EZj/GNusIZzaOaX0Oz/SjQACiPA7Nv+CazqbWnBhr00BVqdHsIgUCmEC lR/CvFVMvSu+wROQ3W5qVG29dVZ5M0I6bjxOlgOXyFUqhqlWZmhd+3KugMDtxXAT8eRAiiAG9 7Xh5ijM 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: Tue, 11 Oct 2016 09:40:41 +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/vpbe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c index 9a6c2cc..8c062ff 100644 --- a/drivers/media/platform/davinci/vpbe.c +++ b/drivers/media/platform/davinci/vpbe.c @@ -676,9 +676,9 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) * store venc sd index. */ num_encoders = vpbe_dev->cfg->num_ext_encoders + 1; - vpbe_dev->encoders = kmalloc( - sizeof(struct v4l2_subdev *)*num_encoders, - GFP_KERNEL); + vpbe_dev->encoders = kmalloc_array(num_encoders, + sizeof(*vpbe_dev->encoders), + GFP_KERNEL); if (NULL == vpbe_dev->encoders) { v4l2_err(&vpbe_dev->v4l2_dev, "unable to allocate memory for encoders sub devices");