From patchwork Thu Sep 29 09:54:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Bolle X-Patchwork-Id: 9357757 X-Patchwork-Delegate: snitzer@redhat.com 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 47F30600C8 for ; Fri, 30 Sep 2016 08:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B79528F77 for ; Fri, 30 Sep 2016 08:05:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 304D329EB2; Fri, 30 Sep 2016 08:05:37 +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=-4.2 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C15BA28F77 for ; Fri, 30 Sep 2016 08:05:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8U82uX2004166; Fri, 30 Sep 2016 04:02:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u8T9sWY2012760 for ; Thu, 29 Sep 2016 05:54:32 -0400 Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8T9sWOs019346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 29 Sep 2016 05:54:32 -0400 Received: from lb3-smtp-cloud6.xs4all.net (lb3-smtp-cloud6.xs4all.net [194.109.24.31]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C887376A10 for ; Thu, 29 Sep 2016 09:54:29 +0000 (UTC) Received: from localhost-localdomain ([83.160.161.190]) by smtp-cloud6.xs4all.net with ESMTP id pMuQ1t00546mmVf01MuSq7; Thu, 29 Sep 2016 11:54:28 +0200 Message-ID: <1475142864.31297.5.camel@tiscali.nl> From: Paul Bolle To: Andy Whitcroft , Joe Perches Date: Thu, 29 Sep 2016 11:54:24 +0200 In-Reply-To: <3861d349-48fd-162b-a749-83e007f70b41@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <080668d9-1e1e-e208-f9ea-ff718e8070e5@users.sourceforge.net> <3861d349-48fd-162b-a749-83e007f70b41@users.sourceforge.net> Mime-Version: 1.0 X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 29 Sep 2016 09:54:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 29 Sep 2016 09:54:30 +0000 (UTC) for IP:'194.109.24.31' DOMAIN:'lb3-smtp-cloud6.xs4all.net' HELO:'lb3-smtp-cloud6.xs4all.net' FROM:'pebolle@tiscali.nl' RCPT:'' X-RedHat-Spam-Score: -0.3 (BAYES_50, DCC_REPUT_00_12, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 194.109.24.31 lb3-smtp-cloud6.xs4all.net 194.109.24.31 lb3-smtp-cloud6.xs4all.net X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Fri, 30 Sep 2016 04:02:16 -0400 Cc: Mike Snitzer , kernel-janitors@vger.kernel.org, LKML , Julia@redhat.com, linux-raid@vger.kernel.org, Lawall , dm-devel@redhat.com, Shaohua Li , SF Markus Elfring , Alasdair Kergon Subject: Re: [dm-devel] [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP Andy, Joe, On Thu, 2016-09-29 at 11:07 +0200, SF Markus Elfring wrote: > * Multiplications for the size determination of memory allocations >   indicated that array data structures should be processed. >   Thus use the corresponding function "kmalloc_array". > >   This issue was detected by using the Coccinelle software. We have no hope of fixing Markus' homegrown coccinelle script. But we could try to fix the checkpatch false positive here. Something like: Does that work for you too? > --- a/drivers/md/dm-snap.c > +++ b/drivers/md/dm-snap.c > @@ -326,8 +326,9 @@ static int init_origin_hash(void) >  { >   int i; >   > - _origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head), > -    GFP_KERNEL); > + _origins = kmalloc_array(ORIGIN_HASH_SIZE, > +  sizeof(*_origins), > +  GFP_KERNEL); >   if (!_origins) { >   DMERR("unable to allocate memory for _origins"); >   return -ENOMEM; > @@ -335,8 +336,9 @@ static int init_origin_hash(void) >   for (i = 0; i < ORIGIN_HASH_SIZE; i++) >   INIT_LIST_HEAD(_origins + i); >   > - _dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head), > -       GFP_KERNEL); > + _dm_origins = kmalloc_array(ORIGIN_HASH_SIZE, > +     sizeof(*_dm_origins), > +     GFP_KERNEL); >   if (!_dm_origins) { >   DMERR("unable to allocate memory for _dm_origins"); >   kfree(_origins); Thanks, Paul Bolle --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 206a6b3..b47201d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5693,7 +5693,7 @@ sub process { $r2 = $a1; } if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ && - !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) { + !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*\b/)) { if (WARN("ALLOC_WITH_MULTIPLY", "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) && $fix) {