Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965470AbcJXW3P (ORCPT ); Mon, 24 Oct 2016 18:29:15 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:47058 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938757AbcJXW3N (ORCPT ); Mon, 24 Oct 2016 18:29:13 -0400 X-Sasl-enc: VezrW7++58d37Ru0nMmMzJT1OEK7i5AALZiLO73j63u/ 1477348127 Date: Mon, 24 Oct 2016 23:28:44 +0100 From: Andrey Utkin To: SF Markus Elfring Cc: linux-media@vger.kernel.org, Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Rafael =?iso-8859-1?Q?Louren=E7o?= de Lima Chehab , Shuah Khan , Wolfram Sang , LKML , kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() Message-ID: <20161024222844.GD25320@dell-m4800.home> References: <68ad1aaa-c029-04b9-805a-e859f6c2d2d5@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <68ad1aaa-c029-04b9-805a-e859f6c2d2d5@users.sourceforge.net> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1555 Lines: 39 On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote: > 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); What about this (for both hunks)? - 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);