Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1725612pxb; Thu, 4 Feb 2021 22:59:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxw98pYZhPP7C8E3kFXf+QxwJFWiDVHar5t0jcGE1yWR868BvjHGtjbGsFweBssXng7iTby X-Received: by 2002:a17:907:96aa:: with SMTP id hd42mr2648922ejc.526.1612508383683; Thu, 04 Feb 2021 22:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612508383; cv=none; d=google.com; s=arc-20160816; b=wXXG93ECTIufxHKowEcHYGHa3mFy1RpCGb/M7mpPIgIs6xsFzcpDdtMAPydp4Rf+gA T80Cog/g76wwfhHtoDtErGjoj85qLuV1sDs/ii+URmBbRNDKIBtIe9QzH6P2pxu5j/yX 5F8uZv3eXLgeEizN5Mqiq1Z1KybILvCZdqfulmRcrha+31KqvCrVAVpdtrMQW33znH7a gymbv62vhchSR1wJ54tYtm8UzezaGdnz3sC9CW9Lj1zavUXPJG9BVB0BF8Gyg6YGou3a r0xYP4yeIziobiPGSQuBEGYQu29pfMebUbZ0iBBI3ntSOoleUsLocDozckGNZxSvAejn KTqA== 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=IoHllK0DVo3KgRZ2t5ipRWPvI5cgNG0bdyV3tVeH5CA=; b=vCmL2fpZEUqMYZf/WRwcnDS4CFNT4A2AVZ1tne52vJ3kbyEkJnEu3cGcSkQwvoYhe+ OTRo1LRIJYITpLzDPtW/K+ybHVJi4nAWMjjgap/Z2sTbqjoH7RI24Po7rzmV29yraTdZ YwFWMyhECZvVfBVwANdikfpEKx+eADhVigtwLuTPnnekl5HDSmYtRpqw33SxmUfoCQvh YkAKHXfJ6xZfZQ7NjxvVswCIRb5aLrdWDbcrGNCaOha9oNZ6feUlzsjS29ptosGY5bkT giR1ogoR+wz76RAiNV3ejQdvL+aPH1Y87XZaF8iGDDWY2l+p8OzSisnuPk3FHFT4BQqG cXUw== 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 o27si5096076edz.400.2021.02.04.22.59.20; Thu, 04 Feb 2021 22:59:43 -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 S231264AbhBEG4i (ORCPT + 99 others); Fri, 5 Feb 2021 01:56:38 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:12837 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbhBEG4e (ORCPT ); Fri, 5 Feb 2021 01:56:34 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DX5kZ4RKxz7hSq; Fri, 5 Feb 2021 14:54:30 +0800 (CST) Received: from huawei.com (10.175.101.6) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Feb 2021 14:55:41 +0800 From: Sun Ke To: , , CC: , , , Subject: [PATCH v5 2/2] nbd: share nbd_put and return by goto put_nbd Date: Fri, 5 Feb 2021 01:56:50 -0500 Message-ID: <20210205065650.2357457-3-sunke32@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210205065650.2357457-1-sunke32@huawei.com> References: <20210205065650.2357457-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; Suggested-by: Markus Elfring 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