Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942486AbcJFJrK (ORCPT ); Thu, 6 Oct 2016 05:47:10 -0400 Received: from mout.web.de ([217.72.192.78]:61409 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S942456AbcJFJrH (ORCPT ); Thu, 6 Oct 2016 05:47:07 -0400 Subject: [PATCH 46/54] md/raid10: 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:46:15 +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:N90ZBfNjualKtecNsTGliJsakUY+4oZuc4aY+TzRshWXoQTZjAV IaaGg6E5VuxH3nuvIiCCtE6ILCCrqZ7QdgZvRFarZtlHTWFI4ebYVudm5E0tGHw7tnjRDn6 H2QkwXhE/VtdRsucnnpYwotk6zs0qcU8bQEq15mviwcUNwWfREDFNwtuZP/EES6rrD1BXfB 6CdkZURaY7SlCvzy4MVhA== X-UI-Out-Filterresults: notjunk:1;V01:K0:PEViKNDY6qQ=:ZVUM2F3zgSA1MU80Xo5prU 8B+mk5FXEAndZomk/tmK+GOxKT9qdtNWqUmyq08Bd6+gMnGS9gzvHcVCiGjKXzohjpTg//t7r 8hgbOK9ksg5dzF7xMnGU5N1bTdyRCeyW2UphBNhbpjlvFStzpLj15SixNR2DLXBb7QDa6Ll/z +DIV6T+pp/5oKjF/8ivc+OCm9ZsgsLM1cYj2cG8522wbMOxGjvrJB7S3L4oFz7Cojw6V6m6Te FU74oWIhfJZKFDslDaAd8CZOzkUBphfXu+ZXFX0PEgebCqmxq9If+f0TR/EIQI1dkwqBnkz94 n8n4Um/1uqrY+YalSf4QCaWdVOhMoaSUmTmCrQgOGv9uOAjzLXiDCF3s1FZViwxFa4ZlKYo76 rCNwnyKp1bPMll6X7qBKZP13ZnMgKZb3CCL9Sh3MxGvse7D3kZFv0vGsU8AN+nEb15A8Z1dNa 8DRtGfUa4w771tPACGh+Kwmz3gQk/LxMtivDC6U2NKxTktvfDo90kztNKmNYB0/i4G50HNv77 XEGrP4f+uEwyj2nrymK4SgzSpJVyczvHIjEYqKwgxOiNUu3P+X14ompbAlgkgwo2i3OXDL8qW qXkZMrF3KcwxvEvwTl8FYyPp47O/kNdyqLq8X4rDLMJwfAdcKRYHYWjirqqhln4GzEcHsB7el nGR6G5XEV7Agxd5rRMtVqvxvGhjNEZuP5GaMn3iCI2D7xCsqQywRavyf5B7fN6+FAPCtAiSmi tQMB4gIcqbx1TV8dir0t1LVytfadco+WxV55P3Epj47RwR/VgzLeU6BN3z8lbVzUMcxsOwXQF DLppqF1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1962 Lines: 76 From: Markus Elfring Date: Wed, 5 Oct 2016 18:32:30 +0200 Resource release functions were called in up to three 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/raid10.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 7e512d4..9b8d11f 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3508,13 +3508,13 @@ static struct r10conf *setup_conf(struct mddev *mddev) GFP_KERNEL); if (!conf->mirrors) { err = -ENOMEM; - goto out; + goto free_conf; } conf->tmppage = alloc_page(GFP_KERNEL); if (!conf->tmppage) { err = -ENOMEM; - goto out; + goto kfree_mirrors; } conf->geo = geo; @@ -3523,7 +3523,7 @@ static struct r10conf *setup_conf(struct mddev *mddev) r10bio_pool_free, conf); if (!conf->r10bio_pool) { err = -ENOMEM; - goto out; + goto put_page; } calc_sectors(conf, mddev->dev_sectors); @@ -3533,7 +3533,7 @@ static struct r10conf *setup_conf(struct mddev *mddev) } else { if (setup_geo(&conf->prev, mddev, geo_old) != conf->copies) { err = -EINVAL; - goto out; + goto destroy_pool; } conf->reshape_progress = mddev->reshape_position; if (conf->prev.far_offset) @@ -3554,16 +3554,18 @@ static struct r10conf *setup_conf(struct mddev *mddev) conf->thread = md_register_thread(raid10d, mddev, "raid10"); if (!conf->thread) { err = -ENOMEM; - goto out; + goto destroy_pool; } conf->mddev = mddev; return conf; - - out: +destroy_pool: mempool_destroy(conf->r10bio_pool); +put_page: safe_put_page(conf->tmppage); +kfree_mirrors: kfree(conf->mirrors); +free_conf: kfree(conf); return ERR_PTR(err); } -- 2.10.1