Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp897643pxb; Wed, 3 Feb 2021 23:11:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0Qwx5kL7mYctBd7dZH06/L4WZYNkN/eas530O0/Uy6ezxCDvX7K4CQ7WEq2SJThGtxwzc X-Received: by 2002:a05:6402:6:: with SMTP id d6mr6691587edu.218.1612422673603; Wed, 03 Feb 2021 23:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612422673; cv=none; d=google.com; s=arc-20160816; b=NnEURV8Hy/mEkkr3PzP9ZbedNSb5l8oUOWooDlvxI2FP4vlDAnWHRbSIWY+J+kvkQA P8rlAN3g4kN9/1JfEaBPxzWiwDIRzP3L/EkuZFSeedqA4OzWfphIHjSpFveVdIGM0ApK 9l75IgaAhsHCSzLMgWsoHrhdqMk2ol52KDPvQ9QUjavHYUzszDPM3TfS9j50/59pPzUG H5WIHGKawYIYfhgPOxMqS/8pjmPvPxDNZnP3QzvZOFN6+8VntN/GXCWbeNtGUrLIgkUu d+4DxElVHjUTBCscn6gFDoUbv9EZIrnC9+KtMOJpU0ZWKYPRiFlA0S/Dik2911RrVmuj 6nmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9KByfg7sXlO4BVULiEinSKDQQyBIKwF3NOPhk/K4gyA=; b=kBsPmdRnryNmEg7ba1jyPZk3HG8cAqPo7A7nPod3HDeBwN0S2KASmBrvQXPigeTfW2 ocemsET7PzYVSnTqtAp8N4yuLrSZ51Ib5pS0WU9jcwuHtbZKKpLm5QDPLyOQaIQDaNKr tk7/piZidkSjJORQfSI82p1KL7ZI3HVbKJMJhegLtpjGckECRbgc6D/Dm7lW7wv+DzRA 4IO/7n/jwM/lxtmk2IBWfF1A1XTXRD/bvRT9VAT+0s5r9XMD7AH1HfU77V/9cGiU52nm FN04CGiSEFyDRLMDy3xCSU5SfvspcoTdy4BhvrlbOJbYtGUTSI04vuuFDS8WvQi4aX37 OpkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm18si2681149edb.545.2021.02.03.23.10.49; Wed, 03 Feb 2021 23:11:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234145AbhBDHIn (ORCPT + 99 others); Thu, 4 Feb 2021 02:08:43 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12021 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234102AbhBDHIe (ORCPT ); Thu, 4 Feb 2021 02:08:34 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DWV2t46yCzjJqp; Thu, 4 Feb 2021 15:06:30 +0800 (CST) Received: from huawei.com (10.175.101.6) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Thu, 4 Feb 2021 15:07:42 +0800 From: Sun Ke To: , , CC: , , , Subject: [PATCH v4 2/2] nbd: share exception handling code by goto put_nbd Date: Thu, 4 Feb 2021 02:09:10 -0500 Message-ID: <20210204070910.1401239-3-sunke32@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210204070910.1401239-1-sunke32@huawei.com> References: <20210204070910.1401239-1-sunke32@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.175.101.6] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace the following two statements by the statement “goto put_nbd;” nbd_put(nbd); return 0; Signed-off-by: Sun Ke --- drivers/block/nbd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 3c9b3bf3f4c2..ecae81e43122 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -2029,12 +2029,11 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info) } mutex_unlock(&nbd->config_lock); mutex_unlock(&nbd_index_mutex); - if (!refcount_inc_not_zero(&nbd->config_refs)) { - nbd_put(nbd); - return 0; - } + if (!refcount_inc_not_zero(&nbd->config_refs)) + goto put_nbd; nbd_disconnect_and_put(nbd); nbd_config_put(nbd); +put_nbd: nbd_put(nbd); return 0; } -- 2.25.4