From patchwork Thu Oct 13 16:18:57 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: 9375309 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 8B36860839 for ; Thu, 13 Oct 2016 16:20:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77E532A163 for ; Thu, 13 Oct 2016 16:20:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69C272A165; Thu, 13 Oct 2016 16:20:20 +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 180862A161 for ; Thu, 13 Oct 2016 16:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756747AbcJMQTx (ORCPT ); Thu, 13 Oct 2016 12:19:53 -0400 Received: from mout.web.de ([212.227.15.4]:65514 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756287AbcJMQTa (ORCPT ); Thu, 13 Oct 2016 12:19:30 -0400 Received: from [192.168.1.2] ([77.182.72.22]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0MNx4F-1bnHfE0o1L-007XPC; Thu, 13 Oct 2016 18:18:59 +0200 Subject: [PATCH 01/18] [media] RedRat3: Use kcalloc() in two functions To: linux-media@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab , Sean Young , Wolfram Sang References: <566ABCD9.1060404@users.sourceforge.net> <81cef537-4ad0-3a74-8bde-94707dcd03f4@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <21c57b39-25ac-2df1-030d-11c243a11ebc@users.sourceforge.net> Date: Thu, 13 Oct 2016 18:18:57 +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: <81cef537-4ad0-3a74-8bde-94707dcd03f4@users.sourceforge.net> X-Provags-ID: V03:K0:dJkXSl6yLZK3h5AmpHpYiBMDsRECgPzEgM/95g8tyayQrdm/Ls4 qEvpm7ZYgzKTYWLsrAFYqDsw/oEKAcVskzK/sGwVdMmve5VGkZmMG/it0IQ2rkZ1v/2Ynq+ /ceahRQ8OI1rw1wneO4JF+yZqgmhtPDufF22pH2p8Qna8fSYuVATfKaWbEk+i3u31L1YLVc 6oEL45rDl4QaczZiy7dXw== X-UI-Out-Filterresults: notjunk:1; V01:K0:CF9b41ui/L0=:/+PyttLath9NiYV0w3Un5p STob8TebTm2pPtF9ts/hxtskdCWyzXSA3YXC++fdD/mdsfEhEWyqg2aRyJs3gpw9fUjZoO2Nv vmeEOKCm0iAK9I+/RQgwuuu+ejOjwP1GNxzpGPjE6tYffx79w8AgQ++6OXWVtedcjClmXNGBG +85GRiXE6Q1yUaousss/zuzNWwAIoCf+BBvEZwyWy4UWELSAYUeCYp3fV4KA/OoVv9tJB9EEE fZUM/W1b+AC7RdxyOEEqnDSbNwOlmyUGJ0VUqO/WsOGJclCRgxR+a4TaUTqrkqzlCDlILdfFV cHd0v29NN78JBy6JrQ1+SaPv3vcljlML5piCC0TrMrfJ3S/75zbAOZj5zX1T00oVLdbrVCBXT 1GOq+3o+wwqzZ/8UBwOpMNSOfVyxWU3RvLPNJTdent3X4acN7HMFY1SMJZL9l3qLLyWd2UOLA /aoIcvtjVuCb6isi6HytRq3VUd9I9C+uXyY2ZnIzuvzCJrw+h60FVTTKSsUbTrQAHo/sYuG+8 i2R1dTF0kzhbE68yOHs83jMFPGn8FuX8h08nvG18fU8v/jp7v64pP+Zee371EWVhbblo3CsHb lHSyXIA9A4vdAVGxvyOHhedBcsgDbBjPVv/dB8uKJjtG0NY5ww5/tb7SDhwkec0ITAoxj2qGB PlNqSy+qZ40FCuIuTeAq2lg49HklWydI0PVfoayF7ZmyvBLnUc+QqjJXpNhrtu3qW0BEGAtr/ SXg7VmmGJHSgFKZj1JrZ4KiB0Rlz26Qot+BjkUBOWcbXWRCOctAvql5Om6BDbqv/ZcZpqjvOt 8hcIko1 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: Thu, 13 Oct 2016 08:35:57 +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/rc/redrat3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index 8d7df6d..d89958b 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c @@ -549,7 +549,7 @@ static void redrat3_get_firmware_rev(struct redrat3_dev *rr3) int rc = 0; char *buffer; - buffer = kzalloc(sizeof(char) * (RR3_FW_VERSION_LEN + 1), GFP_KERNEL); + buffer = kcalloc(RR3_FW_VERSION_LEN + 1, sizeof(*buffer), GFP_KERNEL); if (!buffer) { dev_err(rr3->dev, "Memory allocation failure\n"); return; @@ -741,7 +741,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, /* rr3 will disable rc detector on transmit */ rr3->transmitting = true; - sample_lens = kzalloc(sizeof(int) * RR3_DRIVER_MAXLENS, GFP_KERNEL); + sample_lens = kcalloc(RR3_DRIVER_MAXLENS, + sizeof(*sample_lens), + GFP_KERNEL); if (!sample_lens) { ret = -ENOMEM; goto out;