Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966438AbcJFIzT (ORCPT ); Thu, 6 Oct 2016 04:55:19 -0400 Received: from mout.web.de ([212.227.17.12]:60226 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966398AbcJFIzQ (ORCPT ); Thu, 6 Oct 2016 04:55:16 -0400 Subject: [PATCH 03/54] md/raid0: Move a variable assignment 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: <6df6dd93-d71d-0a14-e5d7-9ee664d6b040@users.sourceforge.net> Date: Thu, 6 Oct 2016 10:54:48 +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:KvH//SbPKFklvnmlPwHuRlq6w6vP4mrvYbyYawwTeJ4rwinT/84 kDPnfeiKzdR81Muurpd704PR5KQ+d7cgdMNBf5sqOheFOfx82CqDdUQW4FiffcY8z/RMhLP JJnSKLvs1YhwZaNUhY8Enu6WJhkoRfBmJvZWuz7NCVQSZUg/wc2/fwG0KE0SrfGuakIgb/d k5ZJ75P1ByU6WH2bcWOIw== X-UI-Out-Filterresults: notjunk:1;V01:K0:bR87iGlsp/k=:Od3XpUxcF1zT9WEUKDQ1N3 u+01YmhBSJMVEog30qf7sbGGYKqDhZmwExZNSPeaJo0FY7WU/2kCUiymoRsI3IFZbUt/iH9u0 ivR/ssmaAPjwZo76q0P0xsRL8gKdEfsTQdnq8pU4viS5WA9uA+PRXAaGWTjFTsD0qssS23EDZ CFa15S+YcMexYRZqasXKpB+t94jwMpI/fm0mri9duzDf7A9wa5QXO9foxxOCV6rp6SKpY7eF8 BW36nh1XQHSMJ5zncDF47yOuciN03pH6hSmAJP2H6htePLtUtXMK8x3gV7LjoDkcIEpwmNLqf a46oOOY89qElCm8HI4aBTD+henE3XEixu7T/oTe2h/dNyx+s/B7f/qCuIOGxEY8URfNd3O+iP JsfMsAz5N8bsKTA/Rmwkx4FNSdE2BZi9jmAPlVROyQQrPwCOSAF5DWS5dKRmcDoro0PobdX+f oUn0wILuWeLYj0n9kdWAvBxeqY1lixE2mOKgd7lBh8JdDXdE+pETFGRdeZ/CA3WFrpFycAUua iBgiBTNbj7g8xYpdL/wOdcITrol0MztXjggk5Xbjli1/sprGsj2bClxZSeq+/HSCpy3LYnmOq GqZLf+mnSVwtwndHSL1JrvsdGd4CKL0nnKqwgWtNVD3QRN4nvhhllMVcruUhC3pTR1iIi2cZF cN9g7ax/OqVmqV36K0a+Waktj101phTehDf9a/jkfyZsPacjOxO+XWxqIcX5M4PP9kBcR7rpV Is7+9CMac+xfyTCYyNHuT6gcazbDSLo/7D3R+yxg0GvJhjnoXj0koTObWj8AwUWyYDnblGrWG TeGsNh1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1277 Lines: 43 From: Markus Elfring Date: Tue, 4 Oct 2016 12:02:29 +0200 One local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignment into two if branches to indicate a memory allocation failure there. Signed-off-by: Markus Elfring --- drivers/md/raid0.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 3c76451..71bd398 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -149,17 +149,21 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) goto free_conf; } - err = -ENOMEM; conf->strip_zone = kcalloc(conf->nr_strip_zones, sizeof(*conf->strip_zone), GFP_KERNEL); - if (!conf->strip_zone) + if (!conf->strip_zone) { + err = -ENOMEM; goto free_conf; + } + conf->devlist = kcalloc(conf->nr_strip_zones * mddev->raid_disks, sizeof(*conf->devlist), GFP_KERNEL); - if (!conf->devlist) + if (!conf->devlist) { + err = -ENOMEM; goto free_zone; + } /* The first zone must contain all devices, so here we check that * there is a proper alignment of slots to devices and find them all -- 2.10.1