Skip to contentSkip to conversation

Bluetooth: Fix return value in hci_dev_do_close()

PATCH In review Kangmin Park 2 participants 2 messages Aug 19, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Bluetooth: Fix return value in hci_dev_do_close()

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.

---
Changes in v4:
- rename variable to err.

 net/bluetooth/hci_core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/bluetooth/hci_core.c +4 -3
index 8622da2d9395..8ed19a07d69c 100644
@@ -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 err = 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);
+			err = 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 err;
 	}
 
 	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 err;
 }
 
 int hci_dev_close(__u16 dev)
Signature · 1 line
2.26.2
maintainer
#1 lore raw

Hi Kangmin,

Quoted 10 lines

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.

Quoted 7 lines

---
Changes in v4:
- rename variable to err.

net/bluetooth/hci_core.c | 7 ++++---

1 file changed, 4 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel