Received: by 10.223.185.116 with SMTP id b49csp6329801wrg; Wed, 28 Feb 2018 07:40:35 -0800 (PST) X-Google-Smtp-Source: AH8x225eW3vmAqOSOvrx6X/zaVc5MaoGhs3klxiDYy9cyzMwrcTPlQiqhjqu3NIGyYX2G04cJgnY X-Received: by 10.101.86.73 with SMTP id m9mr14780709pgs.70.1519832435272; Wed, 28 Feb 2018 07:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519832435; cv=none; d=google.com; s=arc-20160816; b=HZC0jKgPdlYGqYPKpqaoyaGA2wdfOjyMOTCu7Fx9mhiT7dQO6BVIBDhInRyl8LgMy7 h8e2L6NRP4xIKumz9mvYSm3utn13v0VOcI8kwwROykpnZq9HG9bOYb6fkaAGj5hva96q flOHOH8cw8MAumQRV85NmhFUJ/qzN2Rjyehm1IxoiH/L6Jy2TXPjd2/DlbkeHXxI17XU v2XjLwYcThfSAL2jF7DhttfIJp0xZPWEvoFS8vK3Eqr2dy2CbSDSkc+uPMw9CjO5tZsV hH5rasKO90ITapW5tmMo4Nxi4Vd12RiVG5sPtLw/fAiGNkj1kQ3JPVPn6MSuKTEmzMBC dNiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=zC+Vg6pVFEvIFUYdPat7k8mwYmglBkyP3KC2V4sOKtc=; b=iwOjWa8I39AW5TDxF8Dxcq9yt+8wDw0PQpWAoNDm0VPoh3MsYj6uVc8foPHtn2bArr xHHJ884G6lgwm8vOnqUkT1Oq+cgK3cIa7tgKHzcp1pJshi8Kl0kLoSrF6nPZNxNunMlX Zmu9+rEo9/S42wZKUhNk1GBD9KwQLrr/5LrCTG6nGA9nWqKm6QtEVJkj1NimTypo2+Af UYq0kzhz04w5zEYGCgheqfU79AjIV5Fxwp0HIOSBcSMDY9ymacC2CM3sOI+mhzHGBr6/ 8UAJ2ImqBAI336KynkPswu0V2aTzKNkl2+rBTRdz2bj94a9vvgg4CJEbeCoaMH3xWcJ2 80KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c200si1379635pfb.373.2018.02.28.07.40.20; Wed, 28 Feb 2018 07:40:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933058AbeB1Pgj (ORCPT + 99 others); Wed, 28 Feb 2018 10:36:39 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:33284 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752812AbeB1PWf (ORCPT ); Wed, 28 Feb 2018 10:22:35 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yf-0006Xc-H7; Wed, 28 Feb 2018 15:22:17 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Ye-0008RH-Gd; Wed, 28 Feb 2018 15:22:16 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Johannes Thumshirn" , "Mike Snitzer" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 053/254] dm mpath: simplify failure path of dm_multipath_init() In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Thumshirn commit ff658e9c1aae9a84dd06d46f847dc0cd2bf0dd11 upstream. Currently the cleanup of all error cases are open-coded. Introduce a common exit path and labels. Signed-off-by: Johannes Thumshirn Signed-off-by: Mike Snitzer Signed-off-by: Ben Hutchings --- drivers/md/dm-mpath.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -1691,16 +1691,15 @@ static int __init dm_multipath_init(void r = dm_register_target(&multipath_target); if (r < 0) { DMERR("register failed %d", r); - kmem_cache_destroy(_mpio_cache); - return -EINVAL; + r = -EINVAL; + goto bad_register_target; } kmultipathd = alloc_workqueue("kmpathd", WQ_MEM_RECLAIM, 0); if (!kmultipathd) { DMERR("failed to create workqueue kmpathd"); - dm_unregister_target(&multipath_target); - kmem_cache_destroy(_mpio_cache); - return -ENOMEM; + r = -ENOMEM; + goto bad_alloc_kmultipathd; } /* @@ -1713,16 +1712,23 @@ static int __init dm_multipath_init(void WQ_MEM_RECLAIM); if (!kmpath_handlerd) { DMERR("failed to create workqueue kmpath_handlerd"); - destroy_workqueue(kmultipathd); - dm_unregister_target(&multipath_target); - kmem_cache_destroy(_mpio_cache); - return -ENOMEM; + r = -ENOMEM; + goto bad_alloc_kmpath_handlerd; } DMINFO("version %u.%u.%u loaded", multipath_target.version[0], multipath_target.version[1], multipath_target.version[2]); + return 0; + +bad_alloc_kmpath_handlerd: + destroy_workqueue(kmultipathd); +bad_alloc_kmultipathd: + dm_unregister_target(&multipath_target); +bad_register_target: + kmem_cache_destroy(_mpio_cache); + return r; }