From patchwork Sat Oct 1 04:06:26 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: 9360107 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 06222601C0 for ; Mon, 3 Oct 2016 07:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E31CF289A2 for ; Mon, 3 Oct 2016 07:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D74D9289AC; Mon, 3 Oct 2016 07:14:51 +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, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (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 AFCCC289A2 for ; Mon, 3 Oct 2016 07:14:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u937CVIH043122; Mon, 3 Oct 2016 03:12:31 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u9146lTH001478 for ; Sat, 1 Oct 2016 00:06:47 -0400 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9146lY7017416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 1 Oct 2016 00:06:47 -0400 Received: from mout.web.de (mout.web.de [212.227.15.4]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08F6DA49E1; Sat, 1 Oct 2016 04:06:46 +0000 (UTC) Received: from [192.168.1.3] ([92.228.150.161]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0MQ6KJ-1btk4P1Jid-005FRx; Sat, 01 Oct 2016 06:06:42 +0200 From: SF Markus Elfring To: dm-devel@redhat.com, linux-raid@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Shaohua Li Message-ID: <5edaeddf-218f-1a98-d600-84941214db89@users.sourceforge.net> Date: Sat, 1 Oct 2016 06:06:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:PU3qiL8I/IlQk7nfGF9o0NIVclzBo0s48IJGxUGV/CMwX1nTZ8e YJIyMqP6bcrPujSPX3hUVn+Jw9q/fHIsSrEdMkP/vtcr2gmI0FsumqVCn3HuyiuqujDPadY NkqcTC4GT91qrFurdWpaC0uw55W8392lfVlvIRX6f4coAiNPsDn1IM+lLE9mtxVL/1kIW6f 8rcik+Z6M7wJzgVUKximQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:OsXuffWuYIQ=:ZaVFNk+wepSvTbtL7x1Rrm Dqa25GLRZS+e/aKDR/hOMgLmTfqWxj3yBoGDUtJoUg0A5b0SC6M43fJBXesOWmFRuZPCeSlYj 32INBzHOWVK4BU5YHX+JN1aXljOtX+z45bEUM/Rr0HmGsUXrq7/dtos35XlzKNz9s3unc046i AiIRIUMYlZuF58EOvVrInOUpOVyo9Fd7aAg5dPYT1RqRB9gR0WPA7v0LoYM73Hd8hp4Ydoix6 r4V2xspEqAPTkgK6tHFDm5eYy30hwIry4p7vS3vqESnjC3Z/OE0g4PqL1r2R3Sz2R4JohA1bg srO4FrcQfFzpNkOc3sAh6NlfHxOCo1pQ4s1aNm+6GGqd9rzI3cDqUQmMm/n8Cp+VYyotOOY8B yI7b++3/EimxGKSHzQEjOi1FpwVW6YP+F7qkzaBHGLKGON3n7M/aCDJ4DVeHrdKY7AcpVCGh4 kGXc+lI2bQWRazVGIDA6DwSxB0g47LKMqI6DRq0EzzHKX5E+eavCwzr0D4N1nHzt7XjOAVVYw 1ljVzD0GoqasToWiPmdgxyQu+RvPMJqEI4Bbb9lLGtJ+UtP32Mvne6634kBVUwmg417wsN8TM L1t9vRdl/ASVFVtADemhhx3rTD2pqJfoovUAb38EnWoQMwHYrq04/Lrzd2YreOhlK0ON4p48f mZPgsfReUuEfYfdMFagBsKO+8MNMD7qlEj5jOUTDnXuMW81LcjQ7J9B4V+odq2I/I6b7FFPIX TyPRLPmc5p8JRCigj//SVbOmfgiEpXfS1Y/kRH8E8R0SRxwATkiz2Py0u/erODq3VCNEJ/ZHu yCvskTf X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 01 Oct 2016 04:06:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 01 Oct 2016 04:06:46 +0000 (UTC) for IP:'212.227.15.4' DOMAIN:'mout.web.de' HELO:'mout.web.de' FROM:'elfring@users.sourceforge.net' RCPT:'' X-RedHat-Spam-Score: 0.079 (BAYES_50, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 212.227.15.4 mout.web.de 212.227.15.4 mout.web.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 03 Oct 2016 03:10:51 -0400 Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML Subject: [dm-devel] [PATCH] md/dm-stats: Use kmalloc_array() in parse_histogram() 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 From: Markus Elfring Date: Sat, 1 Oct 2016 05:55:05 +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/md/dm-stats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c index 38b05f2..7b79425 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -917,7 +917,9 @@ static int parse_histogram(const char *h, unsigned *n_histogram_entries, if (*q == ',') (*n_histogram_entries)++; - *histogram_boundaries = kmalloc(*n_histogram_entries * sizeof(unsigned long long), GFP_KERNEL); + *histogram_boundaries = kmalloc_array(*n_histogram_entries, + sizeof(**histogram_boundaries), + GFP_KERNEL); if (!*histogram_boundaries) return -ENOMEM;