Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967226AbcJFJKJ (ORCPT ); Thu, 6 Oct 2016 05:10:09 -0400 Received: from mout.web.de ([212.227.15.3]:57358 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966777AbcJFJJr (ORCPT ); Thu, 6 Oct 2016 05:09:47 -0400 Subject: [PATCH 13/54] md/raid1: 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: <7bc6f8e0-5e74-08fc-74f3-33284786ea1e@users.sourceforge.net> Date: Thu, 6 Oct 2016 11:09:18 +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:lgDJYv0diB59hPGRSVwzr1Rhh/b+FMsEUjZ/YM7s+bjrjqx9sGa fWz8G2K3/CkUHxXj6z8KeRDr71AqGystSO/s/9fhbo2bpkJO0QItRhCNyElgrEoNbpwG4rn MErJlyuDo8ncetlXJjYIzRTDCRpIcWepQIPx35kkUs1WnAUPyNlYF/07iaZ1aw0hZXtGMcj oUCv0okp4ttfUE8xDXdHw== X-UI-Out-Filterresults: notjunk:1;V01:K0:Kb3JPBEpuuM=:Uoxa2tIfOeiuOGQKdPJxHy oxujifiiI5bxr0T3+/n3yiOZnWLLloUy52lBop3KyVxO2nQW1cJJBk/CNyOpQwXS0dlmSZeq4 Hfd084dxtJ75kIxaz2XnWoYftJ6sRrvegj40nHpNDVO4zmSMCHoE70ytcJaTYIMCGa3c+imes p0+0r6ClBBN/MCy8v3Y2oBnFhTV2iobyNzqR94R6eCpxP7tNr62xAVkXe/TA8I7h/DwS8ahl4 dpWBOCC9gASHxSIG/FV0NaTJfcLrqRVVguAdbza5Dnu9YyD0K/v07Cp6VT3w+E81sbmxRjCvZ Q3otKKMUoty+TiC4CdWgnzpf8f4sCKNzlmMsXLCv/oyD5t/7NS1YrSy/HkAWVSuO00x9LuKfB MZUXcUMwEHtjuff6lYh0Z9vRwuKnxqswAp5bfFFCOs5n5aaPUiDncsiZ18UtKPHpiTiz7OMGr uoxlumGTVemuqAWtDqej9KsNN4g0RjpTPoVvz8Kwv0Zl16ZSPOQJcZ6l7TlTZohpZYuNXSLhh TvaD8mEjxqou4CxM/lFA1klXl+GF3HMAMZLhKxrz82btRRQDnkMW4pHMPE6U1iL9gmNrVRI72 N4r9hF4xs/2S1xdXCO3C3CzEpffVIrto1CwyjrFo41wR/QuQPOabXNw2jVbizrit0pD2G3vQr r8Clp+IPtbGwtyNuP6RABSPnLIEx4WVkc2d6vEMyeJIAgq3LpwdJNoS4iBFBNFkDqmJBrEHzq 14jsmTiLDQofN257WP27W637RItV2acRFfM9NzlnkeKVMPnkcILsag5McBDWW3YjgOc0x0tfU r5MRKwe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1329 Lines: 50 From: Markus Elfring Date: Tue, 4 Oct 2016 15:56:41 +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. * Reorder two calls for the function "kfree" at the end. Signed-off-by: Markus Elfring --- drivers/md/raid1.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 5969711..74346f5 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2779,7 +2779,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) conf = kzalloc(sizeof(struct r1conf), GFP_KERNEL); if (!conf) - goto abort; + return ERR_PTR(-ENOMEM); conf->mirrors = kcalloc(mddev->raid_disks * 2, sizeof(*conf->mirrors), @@ -2880,13 +2880,11 @@ static struct r1conf *setup_conf(struct mddev *mddev) return conf; abort: - if (conf) { - mempool_destroy(conf->r1bio_pool); - kfree(conf->mirrors); - safe_put_page(conf->tmppage); - kfree(conf->poolinfo); - kfree(conf); - } + mempool_destroy(conf->r1bio_pool); + kfree(conf->poolinfo); + safe_put_page(conf->tmppage); + kfree(conf->mirrors); + kfree(conf); return ERR_PTR(err); } -- 2.10.1