Re: [PATCH 08/13] Bluetooth: hci_sync: Fix return value of hci_reset_sync()
From: Zijun Hu
Date: Tue Jun 23 2026 - 06:48:19 EST
On 6/22/2026 11:35 PM, Luiz Augusto von Dentz wrote:
>> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
>> index fce9f9526cb5..601d44ef975f 100644
>> --- a/net/bluetooth/hci_sync.c
>> +++ b/net/bluetooth/hci_sync.c
>> @@ -3678,8 +3678,10 @@ int hci_reset_sync(struct hci_dev *hdev)
>>
>> err = __hci_cmd_sync_status(hdev, HCI_OP_RESET, 0, NULL,
>> HCI_CMD_TIMEOUT);
>> + if (err < 0)
>> + return err;
>>
>> - return err;
>> + return -bt_to_errno(err);
>> }
> There seem to be 2 consecutive changes to hci_reset_sync that conflict
> with each other, also the expectation should be that positive errors
> are HCI errors and negative errors are stack generated ones, so the
> callers should really check `err` and not `err < 0`.
Hi Luiz,
Checking the full call chains:
- hci_reset_sync() → hci_init0_sync() [if (err)] → hci_unconf_init_sync() [if (err < 0)]
- hci_reset_sync() → hci_init1_sync() [if (err)] → hci_init_sync() [if (err < 0)]
A positive HCI status from hci_reset_sync() propagates through
hci_init0_sync()/hci_init1_sync() but is then silently ignored by
hci_unconf_init_sync()/hci_init_sync() due to their if (err < 0)
checks.
Will not change hci_reset_sync(). Any suggestion on how to fix it?