Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965939AbcJFJ0l (ORCPT ); Thu, 6 Oct 2016 05:26:41 -0400 Received: from mout.web.de ([212.227.17.12]:53574 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965540AbcJFJ0i (ORCPT ); Thu, 6 Oct 2016 05:26:38 -0400 Subject: [PATCH 27/54] md/raid5: Return directly after a failed kzalloc() in setup_conf() 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: <1490c223-763b-b64c-b685-e3bdaa32923c@users.sourceforge.net> Date: Thu, 6 Oct 2016 11:26:04 +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:SVKRtWG7uW2szI658ipgcd0aNr5c6NwicsnInkabRi4OPVqb0DX Rq7mmypKJCD89BtbsXJ979C9h7wYHa0NkoApkGzOPtdl6OP0fRnxZi0faZRS9uKTeoQAGel q5EwAehXc/ic/C0AOhFJv3jS5goKGZ8HGaKP0MCYB6lPYryeoUAZyWUfujxeAYaqNJKvEw9 j6DluxrIb3W1APN5fO6HA== X-UI-Out-Filterresults: notjunk:1;V01:K0:eVEbqm0QyFQ=:QbXSqfZ1eg9Db7yNRr+X4H Z1bubATDsI1IGK3BDoHig1F5NIAC/LWU3y1OiJOzlqbABoUFvuk5q2ouJ+6WaLE9IPwnYF92u mNbq11SzXtLU+zdgLXhvRfEHEyzRlExzh/IalVUIixT2p81Kbk8sHlFDaD8IHWU6CZD3GRFFK GR0s7uL5Ci/99W4ZvoTs2VKBRd8ZAEJQjnP8pGmF2kfm04pB09ATfn45A5qr9kiVL0sHeMwmV Ym4YUUAyn4bHbeEVh9c2GcnrKEM+mcrlSXaExN35Yo8YkAYcflGMWuBmSNd6RB90gm/cwocJS emOSZFnUJbdoWByzJSkLakYC0al80Nm6ifjpAWyY3br0+MpxFkmw5S4VvUZ4DkRRwU51B/Dbv sazz+ejm9FM4iEz4DXMGBS5Td8xaonY1nDgQuSzz7nMGxdODVSKPdl2AqJqHhl98txiPir/QI bl36TbQEivovm5pBy5+YDIx3vwvpiiJpnYZkoP//nUEXzyYbKe1atiJ91Aw+SBI3ITFx4hZmH bADgVD3yHxv5C5mqABoqMSwKa+WHmEJ1WKz/B17dtaj0XknohoVMTEs4gNVvzSmIfG1fFAqew 9iToBpPEOWL8nLMEBqRLOXskHq9G32NiKfMIp2UCcJNAY2Nc1EKdShB/6YwY8lF2emnfE67IX +bF2tmHf0GHLalQp0ncW+u2sLR3sgqIhHOoCH9QYBSuFLxzl5hIzIkQzOOTGlkBAf3Dx4Mq00 fwjG0jlCofkWutiSRxdP3ptMJfQEOt3k5Ws2MVt7YQYRIfRJZs76JphZLpvzvTexzsF0rQg8E PLh0UEJ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1252 Lines: 45 From: Markus Elfring Date: Tue, 4 Oct 2016 22:44:59 +0200 * Return directly after a call of the function "kzalloc" failed at the beginning. * Delete a repeated check for the local variable "conf" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/md/raid5.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 562138f..17f50a6 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6482,8 +6482,8 @@ static struct r5conf *setup_conf(struct mddev *mddev) } conf = kzalloc(sizeof(*conf), GFP_KERNEL); - if (conf == NULL) - goto abort; + if (!conf) + return ERR_PTR(-ENOMEM); /* Don't enable multi-threading by default*/ if (!alloc_thread_groups(conf, 0, &group_cnt, &worker_cnt_per_group, &new_group)) { @@ -6646,11 +6646,8 @@ static struct r5conf *setup_conf(struct mddev *mddev) return conf; abort: - if (conf) { - free_conf(conf); - return ERR_PTR(-EIO); - } else - return ERR_PTR(-ENOMEM); + free_conf(conf); + return ERR_PTR(-EIO); } static int only_parity(int raid_disk, int algo, int raid_disks, int max_degraded) -- 2.10.1