LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3] Bluetooth: Fix return value in hci_dev_do_close()
@ 2021-08-17 6:44 Kangmin Park
2021-08-19 15:07 ` Marcel Holtmann
0 siblings, 1 reply; 2+ messages in thread
From: Kangmin Park @ 2021-08-17 6:44 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Johan Hedberg, Luiz Augusto von Dentz, David S. Miller,
Jakub Kicinski, Tedd Ho-Jeong An, linux-bluetooth, netdev,
linux-kernel
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 <l4stpr0gr4m@gmail.com>
---
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;
}
int hci_dev_close(__u16 dev)
--
2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] Bluetooth: Fix return value in hci_dev_do_close()
2021-08-17 6:44 [PATCH v3] Bluetooth: Fix return value in hci_dev_do_close() Kangmin Park
@ 2021-08-19 15:07 ` Marcel Holtmann
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2021-08-19 15:07 UTC (permalink / raw)
To: Kangmin Park
Cc: Johan Hedberg, Luiz Augusto von Dentz, David S. Miller,
Jakub Kicinski, Tedd Ho-Jeong An, linux-bluetooth, netdev,
linux-kernel
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 <l4stpr0gr4m@gmail.com>
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-19 15:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 6:44 [PATCH v3] Bluetooth: Fix return value in hci_dev_do_close() Kangmin Park
2021-08-19 15:07 ` Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).