Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965596AbcJFJki (ORCPT ); Thu, 6 Oct 2016 05:40:38 -0400 Received: from mout.web.de ([212.227.17.12]:61946 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964849AbcJFJke (ORCPT ); Thu, 6 Oct 2016 05:40:34 -0400 Subject: [PATCH 40/54] md/raid10: Use kcalloc() in two functions 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: <4c7682bf-fef4-a9a2-9205-e47fc030b683@users.sourceforge.net> Date: Thu, 6 Oct 2016 11:40:01 +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:q7Y1f1C+y5lcEVD3635fpaSXPc8ZdBPIdZ/wS1FhTOpSEIQIgVr AKvzzn49aJYvoidN+D03RgV5pPhiAmdZgOC4IK6PedQWmUNl9lZH1HXJus8c8YKH+S8oznp ID9iEiizz9MtAzIdmatsz6RslKLLmHS2BqnqTVrx6LNkGoFQE5J9MhzYN6g6lsA58oJcAbr YrnsCciJhSJOMjnLc8g6A== X-UI-Out-Filterresults: notjunk:1;V01:K0:JlUriZN3vps=:/fwChF4nBjoSUyjz+Thl1T owEPctQm4nFXWzH//Z2RDVEvZ1zwvcZphyStyL+Aru0GFmXbWyAYYSkz5TUvsmI4eMaxABLBR pm6spknYoZ6JuH2lF7vJZIXDSYPk4ewqRqmoQ+WpQtzuH5+u2Ct+gybNCb5GO+aKuxZWjOWeV LxBuprCbUvM6rNQdj/2eYgWIK2v+ru3NwBXJapNtVJIlOVnTtX73+0jtdFvb+B0PpByHQfP1K vi554pXW0FXmDboRoN9AcfT51oN3a4yyimTu9Tlc1+/0XubXXp3SpZyRDMG5TgmtonW3hWFWj 1wkUwbMIdsVIAVn4w3h/V0Kbx/3wKPBOCVJ0LeJdnJxyY4XN+GnHmZHyM53GcMvPfcyWhUEV4 Xebq1/6WHwMLhIkVbXoGh+lfCWIYZMQ7juDMyL7y3Y2LEJN/lJM+MZWudmveWwY5JBYOdQtID YWH8A97uMNPU9Gb8nJg8eN3gShT5UzKVt8CcYR1NSAPVhwmqw+3rGo+SzS7b3qztaZ7dnaPyv 5/DDr+VmO45gRDZ/9+MxJe5Md2zQMykA6gSoM9B1XTiFkuS+tQtIFKIzgxDp1LKi+umLePZcd JvMJ7aGWHPtuK+2wDJcdyJWI+K1JvtKhjf/mZ5EuBwpiUzio9DXxMhkKwS6vqyP19jPHeKkd3 1fh3d+c66jJ7XdzJuWooxEnWGZB9yYwNoIgGhxO30QFTIgQ2t2uxjsCTL4aTX8dRtbLLzkIlk n/y6BGs+8SC5/y/dibJ+e5PVE4caKEqdj2b8mMgzcbYd1f3ivEJfwUHBBipBdB9p+a2E/7IoP URU+xbS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1706 Lines: 51 From: Markus Elfring Date: Wed, 5 Oct 2016 16:45:05 +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 structures 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/raid10.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index be1a9fc..17352a9 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3504,8 +3504,8 @@ static struct r10conf *setup_conf(struct mddev *mddev) goto out; /* FIXME calc properly */ - conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks + - max(0,-mddev->delta_disks)), + conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks), + sizeof(*conf->mirrors), GFP_KERNEL); if (!conf->mirrors) goto out; @@ -3936,11 +3936,10 @@ static int raid10_check_reshape(struct mddev *mddev) conf->mirrors_new = NULL; if (mddev->delta_disks > 0) { /* allocate new 'mirrors' list */ - conf->mirrors_new = kzalloc( - sizeof(struct raid10_info) - *(mddev->raid_disks + - mddev->delta_disks), - GFP_KERNEL); + conf->mirrors_new = kcalloc(mddev->raid_disks + + mddev->delta_disks, + sizeof(*conf->mirrors_new), + GFP_KERNEL); if (!conf->mirrors_new) return -ENOMEM; } -- 2.10.1