Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967062AbcJFJMS (ORCPT ); Thu, 6 Oct 2016 05:12:18 -0400 Received: from mout.web.de ([212.227.15.14]:51264 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966161AbcJFJMO (ORCPT ); Thu, 6 Oct 2016 05:12:14 -0400 Subject: [PATCH 15/54] md/raid1: Less function calls in setup_conf() after error detection 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:11:14 +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:CCpSgDYB44fqCQZAnmr+/fJWFPyClAC95HM1CLteJFP9FEXlmgd pF9piP7KqMSZbFtSJsOUZNLt4alCrgn23Rg/I+GnFTsBlRKQbR/yf8aciPIm1LQc9XOcqhb tpWNfJ6uolneFSAoPARDep+qpr0ncKzSwl2AQu3ejSMba5B2TWbCCgEcmGhTrwI6cLKf9dz 01Dl5ySCFodGFi3TJuzQw== X-UI-Out-Filterresults: notjunk:1;V01:K0:Lrgt+V9i7/4=:r4xOyYBmDbhPL/v9Z8hQlt hQ48/XticIMPLhA8xrKUdBpr10js9cm8Ne+bT0a+jSCd/8s4osZZneDGfFUczqnck1YEZRyOK Ust5j5H+kdIIwIUCF8fOmJLOrLMRuzwXBplHFAr+brb7v+iU4z2r4bMDVK2JOxMvw1p3dYrjl LJ6WfKtEIhuBD/aW+8aASv7iobiRHKBkpm4+sdBfu3PkJrvkHpLcBgKtFIk7NG5j2yrRcfV3z +sQRrUBOFtV2OtkS9chv/VmCWdlcVK9+osVABxBCqGKtmBfdR1MjJoE0HmqoHXUZ6BXUmW1ey w9snwok2PYJ9BWAYXqouJuPdJwZxChQMgNnpVnPny7tzCyTcbymzYriyXL/5NEMU97C54xoEf hKcdJkAyG8BChEkor26JTcvwlExLWDfMZd3IrcgVaL0UKCWCmR0bWNgMavnFvG7dAAkFZgt1A 2/7uBMzbmVInmCId/51pVO9Esowb0SktrkSstxPPkXznZiRN8LkpPgNsEMCDIVeIG1D9ixtlO PCqIQYAHoRDBzRPWxLz53C0GGYN7cAgA831UqCEbSK4w9ojJCffgop3WfTNEA6d93YVkMhity awdrXvBHvCrNLoxvYOnDakq0waMfpyjmRKD8oGOA4TQ6okPmcgevWXjaddAfRbNylaPz5F+OD DX5K59jKyNHROQtQzgrt0ZRB32OWCqQrkaZr0u0MCKFoJ3mj3pImePdejWAS5SsR43oA2BQq/ UgGagD5mrRf/xpYzMVqaROipkBLGsi/WBNhHZ8KwdAkvL/I9aUeA3+T21k+eB8df8woE/fJZc 6mvjqvH Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2282 Lines: 93 From: Markus Elfring Date: Tue, 4 Oct 2016 18:01:02 +0200 Resource release functions were called in up to four cases by the setup_conf() function during error handling even if the passed data structure members contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/md/raid1.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4d2fcbc..7dc45ba 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2786,19 +2786,19 @@ static struct r1conf *setup_conf(struct mddev *mddev) GFP_KERNEL); if (!conf->mirrors) { err = -ENOMEM; - goto abort; + goto free_conf; } conf->tmppage = alloc_page(GFP_KERNEL); if (!conf->tmppage) { err = -ENOMEM; - goto abort; + goto free_mirrors; } conf->poolinfo = kzalloc(sizeof(*conf->poolinfo), GFP_KERNEL); if (!conf->poolinfo) { err = -ENOMEM; - goto abort; + goto put_page; } conf->poolinfo->raid_disks = mddev->raid_disks * 2; @@ -2807,7 +2807,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) conf->poolinfo); if (!conf->r1bio_pool) { err = -ENOMEM; - goto abort; + goto free_poolinfo; } conf->poolinfo->mddev = mddev; @@ -2825,7 +2825,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) if (disk->rdev) { err = -EINVAL; - goto abort; + goto destroy_pool; } disk->rdev = rdev; @@ -2866,7 +2866,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) if (!test_bit(In_sync, &disk->rdev->flags)) { /* Original is not in_sync - bad */ err = -EIO; - goto abort; + goto destroy_pool; } } } @@ -2886,16 +2886,19 @@ static struct r1conf *setup_conf(struct mddev *mddev) "md/raid1:%s: couldn't allocate thread\n", mdname(mddev)); err = -ENOMEM; - goto abort; + goto destroy_pool; } return conf; - - abort: +destroy_pool: mempool_destroy(conf->r1bio_pool); +free_poolinfo: kfree(conf->poolinfo); +put_page: safe_put_page(conf->tmppage); +free_mirrors: kfree(conf->mirrors); +free_conf: kfree(conf); return ERR_PTR(err); } -- 2.10.1