Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4384658pxj; Wed, 12 May 2021 04:37:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5p64utbi7obfbVTTvp0fHPYf+SqDq8LF/eLnM9GO8C9FisqTdRYgM9LQIYM8WY9MIU4B4 X-Received: by 2002:a92:4a10:: with SMTP id m16mr3962540ilf.257.1620819450493; Wed, 12 May 2021 04:37:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620819450; cv=none; d=google.com; s=arc-20160816; b=dZHHm2LNhDeyrpEAiND6SS90y6fRs6ctMfFWV8UEWmYi1CaqZUlALEIEqkhnUaisJE 3sngU0Y7xX6coT2NJUSG20F4QI1ghFVTSboZNRctsRWnJ7zhG0Xa4ydhFtgw4Dn3vD4G /zuet8Ch0yCVOLVz8xqXebI6462lCFxq3D7mG/Uh1PitQXsVI+TmOpMYx0Qp97/1HABL 4cEBflqm6RK16iWlefrFK5bYHERb85ruzk/OiLXOjceK2/Op2qP8r9IqWuHqH1HaEcdM PC9fHmuXDfDOi1SJGTW4bSdl7EwURdir3X3KENJn1hJ+ad3wd2mHQ+2r83KLUip0qzC4 uBuw== 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=cApgey/1TpuOddeMe1NuljurEGczWhCxFN4bvLfT2Ec=; b=o61+5Di/YwZ0lbKlxtXZy9ydX24shEM7s8OodDbh28ahN87XX2lhnVvgyaqmARpl0e 9jE577qYTEJ7e5N0wlL0TlhcvGQX0CWZuzv1XP0svdqhHi0+9ZTN/V1pKumQ98/JYPlf 68LD5w3dykEE9fFXYF5dZPL2NCyNPQqQrhCM2WLXM06Gh1o67Csc/LkQkD8bzOOwoj5V cTUjyffzRuMxUQ0fOBN9DS0g5nvzBmrjqH5sxw0XyQHICMN7+Nn/BJdxWjfyxvKIC+0a v/i1d0hwXBPiQfLIKRxmhgTev4d6ACudExBsDHdOQs0/NXbpy2+OCaJyBa8QgQ9+LkGc JIJw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si26053017iol.19.2021.05.12.04.37.17; Wed, 12 May 2021 04:37:30 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbhELLhU (ORCPT + 99 others); Wed, 12 May 2021 07:37:20 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2716 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbhELLhT (ORCPT ); Wed, 12 May 2021 07:37:19 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FgCN96dqwz1BLVZ; Wed, 12 May 2021 19:33:29 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Wed, 12 May 2021 19:35:59 +0800 From: Sun Ke To: , , CC: , , , Subject: [PATCH 2/2] nbd: share nbd_put and return by goto put_nbd Date: Wed, 12 May 2021 19:43:31 +0800 Message-ID: <20210512114331.1233964-3-sunke32@huawei.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210512114331.1233964-1-sunke32@huawei.com> References: <20210512114331.1233964-1-sunke32@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.175.127.227] 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 Suggested-by: Markus Elfring Reviewed-by: Josef Bacik --- 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 974da561b8e5..45d2c28c8fc8 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -2015,12 +2015,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