Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966222AbcJFJXp (ORCPT ); Thu, 6 Oct 2016 05:23:45 -0400 Received: from mout.web.de ([217.72.192.78]:52966 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964918AbcJFIvy (ORCPT ); Thu, 6 Oct 2016 04:51:54 -0400 Subject: [PATCH 01/54] md/raid0: Use kcalloc() in create_strip_zones() To: linux-raid@vger.kernel.org, Christoph Hellwig , Guoqing Jiang , Jens Axboe , Mike Christie , Neil Brown , Shaohua Li , Tomasz Majchrzak References: <566ABCD9.1060404@users.sourceforge.net> <786843ef-4b6f-eb04-7326-2f6f5b408826@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <2eaf3755-ff33-39e0-517c-c968d148f862@users.sourceforge.net> Date: Thu, 6 Oct 2016 10:51:25 +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: <786843ef-4b6f-eb04-7326-2f6f5b408826@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:0SwIl45Ki7BToFoxBt/H7X+60xtQxz2GTbfjMLeRfpfE8F4zwFB CNI8hxbdaJu8Mbwh3yF+zV7lSwGDzMYHS2LI/2t7cFu8nAp8a3ygDfD38n3ii/5dAHmn1T2 vSvYbSpxLD8xtPtOC91FCIgwp8fIxBkqQ9BggjlRJRBpAr6CEz9kW8E7JYA3HctMiPczKA0 jvbgDuDOwv2vf/VM0fp7Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:p7j60HK5sOs=:StIE7WLUBsuwjJ2nQMtoJL gqsQL3hQwgLaSa0iLsfaaXlAubZi3kiuZbh3k0eZ9zlxZPbHFvfpLidENGZCrc+UwakAMeuQ8 x/PZwvyAXikTfTbqBxfr+/7Y8eZ+8T0NzigApFj1VmsnOWSG0pZmNTPiycuQz+oTupolx7C0M F7cxvRzBv4Bbi5c/Ycyh3/7Rx0TVJoHboj2/feO0SuhblJdUyVc1PcxNmElm32f1lTJTRib5H v14m023XJEquygjn5x2e6bUhhrkUsAFYMfhXT7OSLAr8BZyUmoJtiQCDDKUXS48yJfDOwYGFJ VuuB7TjzqKDA5YrblSxaKIOGiSScpAzQ4JP0Eq96HjoyLv03jxSkf1o+zL/hMaf8SSAWuDG4V X2XkthjovsE1SDwzqSU/HTz4f49m4AihkHYnMm0WgtCQADDAkGgDNrvUrnSJ3Uk/fp+CXLFFa Q9DE2eW+ZvLg3UtMd/Ee2PKqv1qkpWVMvheixmkcjt6kkUVoVpST28njb3l3TkshHkWjzXEEY HBIDKjNAajfnpSqBiJo4b9JBdIa/0aWOK2UG605WFppB/FiaYtMyA9V2GngL11kBZI7gC+y7I zn6UCFdrsSkqDaHQQVw5XI5Bez/efKkjrBL37w4zlPZDqMDmVFf9orlK5I7yAFoG3RB1hhdAY m6oEdhGu2TCl5/X+ZKyU7amzctnJWQRd+2832+JQM9G5aFd9ylDSbf0gZaNNXctQhI23tbSZZ muLi+IAxSFPUhNoLgj2eDtBo7Ebls6jcnhMSeltU+KV5TgW2Ee256fgRCwPlGt4BcTgK6Ka+b SEuucId Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1416 Lines: 42 From: Markus Elfring Date: Tue, 4 Oct 2016 10:10:52 +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/md/raid0.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 258986a..50e8a63 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -150,12 +150,13 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) } err = -ENOMEM; - conf->strip_zone = kzalloc(sizeof(struct strip_zone)* - conf->nr_strip_zones, GFP_KERNEL); + conf->strip_zone = kcalloc(conf->nr_strip_zones, + sizeof(*conf->strip_zone), + GFP_KERNEL); if (!conf->strip_zone) goto abort; - conf->devlist = kzalloc(sizeof(struct md_rdev*)* - conf->nr_strip_zones*mddev->raid_disks, + conf->devlist = kcalloc(conf->nr_strip_zones * mddev->raid_disks, + sizeof(*conf->devlist), GFP_KERNEL); if (!conf->devlist) goto abort; -- 2.10.1