Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967196AbcJFJHn (ORCPT ); Thu, 6 Oct 2016 05:07:43 -0400 Received: from mout.web.de ([212.227.17.12]:58030 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967080AbcJFJHh (ORCPT ); Thu, 6 Oct 2016 05:07:37 -0400 Subject: [PATCH 11/54] md/raid1: Use kcalloc() in raid1_reshape() 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: Date: Thu, 6 Oct 2016 11:06:37 +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:1ecVOmyc8CZHsnPY7bE2bdiAEs+u8FB0n3fnw9akqugrGibwrNY GpTJKOk5wcBqdnmk51VuJcYgWfnE84Nm2uHPhvNvo90Xb/gq59wkXqWfvnTqXaHKn8QcuHH 5TscazuRGNT0U9whjbh23+HeSMV4btJK974b7K+Gs6I60K6+YxltJF9qeytIZJBx+vLFsUJ DB6ORYclF4d1YmzISSFZA== X-UI-Out-Filterresults: notjunk:1;V01:K0:lPFvtn2Y5ao=:z+sILxOzEPK2Y6xLTHdEqB 40H4n3YpDX+qgFuaf1vPdrN5o/jdlUTNzxKuT/Vgn89iz2vvmUEPBSHf3xSBC0arOQa636DMY vXQXx34ZPFSFzcRBcO4BwihZt9L1fSvnoKaCtwI0Lxps/VLtFUHXxSlZ0cGfTRuOCS8gmtOaz LRc0eMxEfq+fR402cLaQEXn192P3d8bWSJ2GuZb+ATFpjIq/iQbPm2qzUG83kjo1+yr4SrOR+ xYqUVsP/lbTkhRZlDf+GIzLdo7BIEqf/WGWyS3G6IH5DXHzUzphwVji/NHqqeZ0ePtxfQmGYq JzhjWGv7teJCdUM+IF5BwkQFicYJV5VppJ67ndStyyfJZ6NeSmn4owrXOXRfT+LiOioIvM6tw vsW45RtB1aQKS9fsSErJX+R5+lg1rCTJmjQezq74h5pn4WFnOXZtg+oBzizf06onupv66P0H7 8ukzN+7Q4I3Q7CwMjhBZb6IZn1yZBx73MD+ZQSOaNuxyKHP2nh848q0j5aU2t3FK5g7hKOiSF +xjma60jRw1jxGUNnV3DNpCIE9d7GQqDouRdtP8vPMhozFrD2M3MSwN/RCQ/UOO9wfC5RUd2m cG7BL1E/RXCmQB6/pPi8KnDqKAfIShcGXv94H2riYLAnyb5sbkWn3T8JhswoyUJyhqT0T8qbF EZwT5lfFQyDbO5CpF5/xA3COmRqb3KnvzetBcw6Wgf1Be8bETGJ05Z8lqAkO/tjh03/PvYxFS p3Kn4Nvd3XlFsh5LnLuI9jb9fBeY/nW7H1DznHBkKSAEgadfEJpmYuSkikLERdwtJEVxBXDnq 0JS5SDe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1095 Lines: 33 From: Markus Elfring Date: Tue, 4 Oct 2016 15:17:13 +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 "kcalloc". * Replace the specification of a data structure 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/raid1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index d2759f8..e75ae87 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -3081,8 +3081,8 @@ static int raid1_reshape(struct mddev *mddev) kfree(newpoolinfo); return -ENOMEM; } - newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2, - GFP_KERNEL); + + newmirrors = kcalloc(raid_disks * 2, sizeof(*newmirrors), GFP_KERNEL); if (!newmirrors) { kfree(newpoolinfo); mempool_destroy(newpool); -- 2.10.1