Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7325568pxb; Thu, 18 Feb 2021 07:18:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxu6f+aGLpXCz9FyB1eedhNdrUt18XiAZ3yimFrrDmC4d74fbWOQNLYIujX7hUdFvvIccLF X-Received: by 2002:a17:907:3f13:: with SMTP id hq19mr4533173ejc.142.1613661489332; Thu, 18 Feb 2021 07:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613661489; cv=none; d=google.com; s=arc-20160816; b=p4hgU1M8bthmsQvbe1sdBeb2HUeuipRFiP5YfGJKdX99MH2QFJ0nI7LD4/vWLtRjne z9qo9nbQj1mvIKcZUTOEP2/vnh4u7RXCie9FrS1o8wlFpg1OdJWAfeWYRQw2X29dRVnj Rw7DN9MkKBo1HClb00SCThxEpw1cvjfA/d/2lQaxcNU/Z8owwEysXMiyLuSQHyGB8d9T QmBeM97mW8IEPdSejSWS4gba0zEqzt8NtDMUFhpTgCOpKWmRVfvW7DtZGYV9qgb4PVCo Bxj8gX+9hoNbkcyCUD4c36SjGmRFZVem3pMKowSGuUzRD00T9loTJ0ZywG8E/pb2GXsD uXIg== 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=NMEtK18JV5lpxCrLez0yK7z5fZbvuk67qRWufUOrheM=; b=obd06dLZTUVH6ANqwSLFoeeLD1NILktu/or13Ad0IUfzLdw30czSuIhu6wEtFR8KCu TNHgDDV3Fie6pRDXRGHA+ArkZTh2rt4Fn4MzecN38vJuJmLwBEKfv93yJOdD0VeAZY3b iCM0t2aPW40ugB7mKtrvs6Db6/IGkIEUHJKIqhXjxxtxtDRd2UDHrZT1FUmxhn2C5gCV wZxKDqHgbpWEUr7v3S82aDZpN/G0D9k8p5/1rraCRP19x1S8zCAodJlMFacMADNrpewR RczvXdPTXN6bhd+Q/oKdA176ol63UF+Z2weI6kzsYcQl/1Pag+gJeJWS6UsTJjpkanal iWSg== 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 k16si3885119edq.147.2021.02.18.07.17.45; Thu, 18 Feb 2021 07:18:09 -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 S230030AbhBRPQK (ORCPT + 99 others); Thu, 18 Feb 2021 10:16:10 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:12980 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbhBRMXt (ORCPT ); Thu, 18 Feb 2021 07:23:49 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DhDL91Km1zjNbT; Thu, 18 Feb 2021 20:20:01 +0800 (CST) Received: from huawei.com (10.175.101.6) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Thu, 18 Feb 2021 20:21:23 +0800 From: Sun Ke To: , , CC: , , , Subject: [PATCH v6 2/2] nbd: share nbd_put and return by goto put_nbd Date: Thu, 18 Feb 2021 07:26:20 -0500 Message-ID: <20210218122620.228375-3-sunke32@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210218122620.228375-1-sunke32@huawei.com> References: <20210218122620.228375-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 403c1e1fe748..10cbb5caad07 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -2027,12 +2027,11 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info) return -EINVAL; } 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