From patchwork Wed Oct 7 15:54:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Shtylyov X-Patchwork-Id: 11820909 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=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 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 9E7BAC41604 for ; Wed, 7 Oct 2020 16:03:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61021216C4 for ; Wed, 7 Oct 2020 16:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729023AbgJGQDu (ORCPT ); Wed, 7 Oct 2020 12:03:50 -0400 Received: from mxout03.lancloud.ru ([89.108.73.187]:39426 "EHLO mxout03.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728503AbgJGQDu (ORCPT ); Wed, 7 Oct 2020 12:03:50 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru BEBF82092EC1 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH 1/2] bluetooth: hci_event: consolidate error paths in hci_phy_link_complete_evt() From: Sergey Shtylyov To: Marcel Holtmann , Johan Hedberg , CC: "David S. Miller" , Jakub Kicinski , References: Organization: Open Mobile Platform, LLC Message-ID: Date: Wed, 7 Oct 2020 18:54:15 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [213.87.153.155] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1908.lancloud.ru (fd00:f066::208) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org hci_phy_link_complete_evt() has several duplicate error paths -- consolidate them, using the *goto* statements. Signed-off-by: Sergey Shtylyov --- net/bluetooth/hci_event.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) Index: bluetooth-next/net/bluetooth/hci_event.c =================================================================== --- bluetooth-next.orig/net/bluetooth/hci_event.c +++ bluetooth-next/net/bluetooth/hci_event.c @@ -4936,20 +4936,15 @@ static void hci_phy_link_complete_evt(st hci_dev_lock(hdev); hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); - if (!hcon) { - hci_dev_unlock(hdev); - return; - } + if (!hcon) + goto unlock; - if (!hcon->amp_mgr) { - hci_dev_unlock(hdev); - return; - } + if (!hcon->amp_mgr) + goto unlock; if (ev->status) { hci_conn_del(hcon); - hci_dev_unlock(hdev); - return; + goto unlock; } bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; @@ -4966,6 +4961,7 @@ static void hci_phy_link_complete_evt(st amp_physical_cfm(bredr_hcon, hcon); +unlock: hci_dev_unlock(hdev); }