Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942461AbcJFJqU (ORCPT ); Thu, 6 Oct 2016 05:46:20 -0400 Received: from mout.web.de ([217.72.192.78]:51834 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S942251AbcJFJqR (ORCPT ); Thu, 6 Oct 2016 05:46:17 -0400 Subject: [PATCH 45/54] md/raid10: Move assignments for the variable "err" 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: Date: Thu, 6 Oct 2016 11:45:24 +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:2rEhhEARW6lFiWqCMoGO7aueQWVtu1wuBR8o7nBD7q7P4pXOvd6 j/7ErMW4TyyhiAcwp+SDht2NL0GUJHc2LFmPrFZTjFivmhhRxlCEvrGGLhp2HJBM62j7WTo /2hsr0an0Xybv0eQx48A8iiZH9V1wJTrn7YzsOEqfQ1NCa2Ju8XoZyHpqjP97vCL8mC19CS Eo8oXsfKhyJIgSb+7YJ2w== X-UI-Out-Filterresults: notjunk:1;V01:K0:T/1U6Dj0SCA=:K078t8FZ3jPmz8AozsFeAh liP6rwhGTgWaKWpcUF5DrmOQuV6nVQ6u/Fllp/jQ2JiQe7Bqc1AiGlC/JlVh1kUWd0ASHX8DK FmAObu5uJ7e8Kp8MFqAXaLgL8tyIOAyJVeH8SX/LjGFclZjOsfBKg3hRH0n2ZsYe3NV8Iu1S+ 6a4TYf22fC7CbnOgp+p2yRWRNr0rK/+Zl5JT9J46wLAEMuWxka0amPE216tvrOwdDIBYryrhy kG69rHit0Useoi2v0NhdeZQbqpcqCd9eWim79GviMLFShGqteMnlBRPGNnlb7W29EvI09gOLn fGnyB5chGgfZ4W37kxewUomRXsrJEVkaGVtRwhWzx75Eh0IQ6dpnsGciznFZb1Rh+gjbB+aka dzUVTAnD2GQlGhim56XRtSwAwO+fY/Xe0k0CrIb2L17a0CjVUjCkrRU7tbnMAkaOwiHgTDq4b DiISrgj0GzNWK1gF9Qb8XK8zqNjdgM4p0cz0PwGb6SccjL5pIFjQKTSfMhC5QMS94NDju8NN1 WGi+mFeNFh4PvwoTTkiOMtNR801vcgwj34Spxsytsd2DrJLUPcBFzr2mEma1FlhtzjuyqETFP K2dNA6k01+l4MhN7bcwg2HmYKTn5BrjFXm2OzC5BWC35+TqBfKXecKkzBWpYoxrtktyrkwfiI 2ZnB9Jn60z44EmtitjSTnixb8x/coNpewgG6X6bURpQ6xxu/dSTnXysDhg9qtbrZIcvVt+kCD ILzjbSxOsEw+1y7g1jsRKA9rtyDfwoh518Q1HZpzdOdKNqxHTmkWBpjMcnKLE65PovY2YC1Wz u7OEhk8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1847 Lines: 67 From: Markus Elfring Date: Wed, 5 Oct 2016 18:26:45 +0200 One local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignments into if branches to indicate a memory allocation failure there. Signed-off-by: Markus Elfring --- drivers/md/raid10.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index abe75c2..7e512d4 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3498,7 +3498,6 @@ static struct r10conf *setup_conf(struct mddev *mddev) return ERR_PTR(-EINVAL); } - err = -ENOMEM; conf = kzalloc(sizeof(*conf), GFP_KERNEL); if (!conf) return ERR_PTR(-ENOMEM); @@ -3507,19 +3506,25 @@ static struct r10conf *setup_conf(struct mddev *mddev) conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks), sizeof(*conf->mirrors), GFP_KERNEL); - if (!conf->mirrors) + if (!conf->mirrors) { + err = -ENOMEM; goto out; + } conf->tmppage = alloc_page(GFP_KERNEL); - if (!conf->tmppage) + if (!conf->tmppage) { + err = -ENOMEM; goto out; + } conf->geo = geo; conf->copies = copies; conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc, r10bio_pool_free, conf); - if (!conf->r10bio_pool) + if (!conf->r10bio_pool) { + err = -ENOMEM; goto out; + } calc_sectors(conf, mddev->dev_sectors); if (mddev->reshape_position == MaxSector) { @@ -3547,8 +3552,10 @@ static struct r10conf *setup_conf(struct mddev *mddev) atomic_set(&conf->nr_pending, 0); conf->thread = md_register_thread(raid10d, mddev, "raid10"); - if (!conf->thread) + if (!conf->thread) { + err = -ENOMEM; goto out; + } conf->mddev = mddev; return conf; -- 2.10.1