Re: [PATCH v1] Bluetooth: hci_sync: Fix logical error when enter active mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/2/2023 5:28 PM, Zijun Hu wrote:
> it seems HCI_CONN_POWER_SAVE stands for active mode based on
> hci_mode_change_evt(), but hci_conn_enter_active_mode() does not take
> this flag rightly and failed to exit sniff mode potentially, it is
> fixed by this change.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
> ---
>  net/bluetooth/hci_conn.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 929d0e313db2..302fb5eaca55 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -2582,7 +2582,12 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
>  	if (conn->mode != HCI_CM_SNIFF)
>  		goto timer;
>  
> -	if (!test_bit(HCI_CONN_POWER_SAVE, &conn->flags) && !force_active)
> +	if (test_bit(HCI_CONN_POWER_SAVE, &conn->flags)) {
> +		BT_DBG("%s: hcon %p is already active mode", __func__, conn);
> +		goto timer;
> +	}
> +
> +	if (!force_active)
>  		goto timer;
>  
>  	if (!test_and_set_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->flags)) {

not sure what HCI_CONN_POWER_SAVE stands for. or change as below ?

@@ -4596,9 +4596,9 @@ static void hci_mode_change_evt(struct hci_dev *hdev, void *data,
                if (!test_and_clear_bit(HCI_CONN_MODE_CHANGE_PEND,
                                        &conn->flags)) {
                        if (conn->mode == HCI_CM_ACTIVE)
-                               set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
-                       else
                                clear_bit(HCI_CONN_POWER_SAVE, &conn->flags);
+                       else
+                               set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
                }




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux