From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 9A7EBC432BE for ; Thu, 19 Aug 2021 15:07:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77DBE60EFE for ; Thu, 19 Aug 2021 15:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239735AbhHSPIQ convert rfc822-to-8bit (ORCPT ); Thu, 19 Aug 2021 11:08:16 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:34178 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238141AbhHSPIP (ORCPT ); Thu, 19 Aug 2021 11:08:15 -0400 Received: from smtpclient.apple (p5b3d23f8.dip0.t-ipconnect.de [91.61.35.248]) by mail.holtmann.org (Postfix) with ESMTPSA id 7E93ECED16; Thu, 19 Aug 2021 17:07:37 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [PATCH v3] Bluetooth: Fix return value in hci_dev_do_close() From: Marcel Holtmann In-Reply-To: <20210817064411.2378-1-l4stpr0gr4m@gmail.com> Date: Thu, 19 Aug 2021 17:07:37 +0200 Cc: Johan Hedberg , Luiz Augusto von Dentz , "David S. Miller" , Jakub Kicinski , Tedd Ho-Jeong An , linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20210817064411.2378-1-l4stpr0gr4m@gmail.com> To: Kangmin Park X-Mailer: Apple Mail (2.3654.120.0.1.13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kangmin, > hci_error_reset() return without calling hci_dev_do_open() when > hci_dev_do_close() return error value which is not 0. > > Also, hci_dev_close() return hci_dev_do_close() function's return > value. > > But, hci_dev_do_close() return always 0 even if hdev->shutdown > return error value. So, fix hci_dev_do_close() to save and return > the return value of the hdev->shutdown when it is called. > > Signed-off-by: Kangmin Park > --- > net/bluetooth/hci_core.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 8622da2d9395..84afc0d693a8 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -1718,6 +1718,7 @@ static void hci_pend_le_actions_clear(struct hci_dev *hdev) > int hci_dev_do_close(struct hci_dev *hdev) > { > bool auto_off; > + int ret = 0; > > BT_DBG("%s %p", hdev->name, hdev); > > @@ -1732,13 +1733,13 @@ int hci_dev_do_close(struct hci_dev *hdev) > test_bit(HCI_UP, &hdev->flags)) { > /* Execute vendor specific shutdown routine */ > if (hdev->shutdown) > - hdev->shutdown(hdev); > + ret = hdev->shutdown(hdev); > } > > if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { > cancel_delayed_work_sync(&hdev->cmd_timer); > hci_req_sync_unlock(hdev); > - return 0; > + return ret; > } > > hci_leds_update_powered(hdev, false); > @@ -1845,7 +1846,7 @@ int hci_dev_do_close(struct hci_dev *hdev) > hci_req_sync_unlock(hdev); > > hci_dev_put(hdev); > - return 0; > + return ret; > } actually use variable name err instead of ret since that is more consistent in this code. Regards Marcel