From patchwork Fri Feb 5 06:56:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sun Ke X-Patchwork-Id: 12069385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6639C433E6 for ; Fri, 5 Feb 2021 06:56:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5F3464F3B for ; Fri, 5 Feb 2021 06:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231239AbhBEG4e (ORCPT ); Fri, 5 Feb 2021 01:56:34 -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 X-Originating-IP: [10.175.101.6] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@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; }