diff mbox series

[BlueZ,v2] device: Clear pending_flags on error

Message ID 20250128115659.23655-1-ludovico.denittis@collabora.com
State Superseded
Headers show
Series [BlueZ,v2] device: Clear pending_flags on error | expand

Commit Message

Ludovico de Nittis Jan. 28, 2025, 11:56 a.m. UTC
If setting WakeAllowed, or the device privacy, fails, we may end up in a
situation where `pending_flags` is still set to some `DEVICE_FLAG_*`
values, for example from `device_set_wake_allowed()` or
`adapter_set_device_flags()`.

This can confuse further requests because they'll assume that there is
still a pending request in progress.
---
 src/adapter.c | 1 +
 src/device.c  | 1 +
 2 files changed, 2 insertions(+)

Comments

Ludovico de Nittis Feb. 14, 2025, 11:22 a.m. UTC | #1
What do you think about this patch? I saw that this was still pending 
while my other related ones have been merged. I'm not sure if you'd like 
some changes or if it simply fell through the cracks.

Regards,
Ludovico de Nittis

On 1/28/25 12:56 PM, Ludovico de Nittis wrote:
> If setting WakeAllowed, or the device privacy, fails, we may end up in a
> situation where `pending_flags` is still set to some `DEVICE_FLAG_*`
> values, for example from `device_set_wake_allowed()` or
> `adapter_set_device_flags()`.
>
> This can confuse further requests because they'll assume that there is
> still a pending request in progress.
> ---
>   src/adapter.c | 1 +
>   src/device.c  | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 5d4117a49..3eb343cbc 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -5580,6 +5580,7 @@ static void set_device_privacy_complete(uint8_t status, uint16_t length,
>   	if (status != MGMT_STATUS_SUCCESS) {
>   		error("Set device flags return status: %s",
>   					mgmt_errstr(status));
> +		btd_device_set_pending_flags(dev, 0);
>   		return;
>   	}
>   
> diff --git a/src/device.c b/src/device.c
> index e8bff718c..3c2337198 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -1575,6 +1575,7 @@ static void set_wake_allowed_complete(uint8_t status, uint16_t length,
>   			dev->wake_id = -1U;
>   		}
>   		dev->pending_wake_allowed = FALSE;
> +		dev->pending_flags = 0;
>   		return;
>   	}
>
Luiz Augusto von Dentz Feb. 14, 2025, 3:28 p.m. UTC | #2
Hi Ludovico,

On Fri, Feb 14, 2025 at 6:26 AM Ludovico de Nittis
<ludovico.denittis@collabora.com> wrote:
>
> What do you think about this patch? I saw that this was still pending
> while my other related ones have been merged. I'm not sure if you'd like
> some changes or if it simply fell through the cracks.

Let me check if it is not on patchwork, anyway you can always resend
when this happens.

> Regards,
> Ludovico de Nittis
>
> On 1/28/25 12:56 PM, Ludovico de Nittis wrote:
> > If setting WakeAllowed, or the device privacy, fails, we may end up in a
> > situation where `pending_flags` is still set to some `DEVICE_FLAG_*`
> > values, for example from `device_set_wake_allowed()` or
> > `adapter_set_device_flags()`.
> >
> > This can confuse further requests because they'll assume that there is
> > still a pending request in progress.
> > ---
> >   src/adapter.c | 1 +
> >   src/device.c  | 1 +
> >   2 files changed, 2 insertions(+)
> >
> > diff --git a/src/adapter.c b/src/adapter.c
> > index 5d4117a49..3eb343cbc 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -5580,6 +5580,7 @@ static void set_device_privacy_complete(uint8_t status, uint16_t length,
> >       if (status != MGMT_STATUS_SUCCESS) {
> >               error("Set device flags return status: %s",
> >                                       mgmt_errstr(status));
> > +             btd_device_set_pending_flags(dev, 0);
> >               return;
> >       }
> >
> > diff --git a/src/device.c b/src/device.c
> > index e8bff718c..3c2337198 100644
> > --- a/src/device.c
> > +++ b/src/device.c
> > @@ -1575,6 +1575,7 @@ static void set_wake_allowed_complete(uint8_t status, uint16_t length,
> >                       dev->wake_id = -1U;
> >               }
> >               dev->pending_wake_allowed = FALSE;
> > +             dev->pending_flags = 0;
> >               return;
> >       }
> >
>
>
patchwork-bot+bluetooth@kernel.org Feb. 14, 2025, 4 p.m. UTC | #3
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 28 Jan 2025 12:56:59 +0100 you wrote:
> If setting WakeAllowed, or the device privacy, fails, we may end up in a
> situation where `pending_flags` is still set to some `DEVICE_FLAG_*`
> values, for example from `device_set_wake_allowed()` or
> `adapter_set_device_flags()`.
> 
> This can confuse further requests because they'll assume that there is
> still a pending request in progress.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2] device: Clear pending_flags on error
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=264bf951f2d6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/adapter.c b/src/adapter.c
index 5d4117a49..3eb343cbc 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5580,6 +5580,7 @@  static void set_device_privacy_complete(uint8_t status, uint16_t length,
 	if (status != MGMT_STATUS_SUCCESS) {
 		error("Set device flags return status: %s",
 					mgmt_errstr(status));
+		btd_device_set_pending_flags(dev, 0);
 		return;
 	}
 
diff --git a/src/device.c b/src/device.c
index e8bff718c..3c2337198 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1575,6 +1575,7 @@  static void set_wake_allowed_complete(uint8_t status, uint16_t length,
 			dev->wake_id = -1U;
 		}
 		dev->pending_wake_allowed = FALSE;
+		dev->pending_flags = 0;
 		return;
 	}