public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: fix wakeup irq devres lifetime
@ 2026-03-30  9:33 Johan Hovold
  2026-03-30 19:17 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2026-03-30  9:33 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, Marcel Holtmann
  Cc: linux-bluetooth, linux-kernel, Johan Hovold, Rajat Jain

The OOB wakeup irq is device managed but its lifetime is incorrectly
tied to the child HCI device rather than the USB interface to which the
driver is bound.

This should not cause any trouble currently as the interrupt is only
enabled during suspend, but it is technically wrong as the reference
counted HCI device could remain after the driver has been unbound.

Note that the data passed to the interrupt handler is not device managed
and is typically freed before the interrupt during disconnect, but this
is also safe as long as the interrupt is disabled.

Fixes: fd913ef7ce61 ("Bluetooth: btusb: Add out-of-band wakeup support")
Cc: Rajat Jain <rajatja@google.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/bluetooth/btusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5c535f3ab722..4c5344ce16c1 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3801,7 +3801,7 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
 	}
 
 	irq_set_status_flags(irq, IRQ_NOAUTOEN);
-	ret = devm_request_irq(&hdev->dev, irq, btusb_oob_wake_handler,
+	ret = devm_request_irq(&data->intf->dev, irq, btusb_oob_wake_handler,
 			       0, "OOB Wake-on-BT", data);
 	if (ret) {
 		bt_dev_err(hdev, "%s: IRQ request failed", __func__);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: btusb: fix wakeup irq devres lifetime
  2026-03-30  9:33 [PATCH] Bluetooth: btusb: fix wakeup irq devres lifetime Johan Hovold
@ 2026-03-30 19:17 ` Luiz Augusto von Dentz
  2026-04-02  9:35   ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2026-03-30 19:17 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Marcel Holtmann, linux-bluetooth, linux-kernel, Rajat Jain

Hi Johan,

On Mon, Mar 30, 2026 at 5:33 AM Johan Hovold <johan@kernel.org> wrote:
>
> The OOB wakeup irq is device managed but its lifetime is incorrectly
> tied to the child HCI device rather than the USB interface to which the
> driver is bound.
>
> This should not cause any trouble currently as the interrupt is only
> enabled during suspend, but it is technically wrong as the reference
> counted HCI device could remain after the driver has been unbound.
>
> Note that the data passed to the interrupt handler is not device managed
> and is typically freed before the interrupt during disconnect, but this
> is also safe as long as the interrupt is disabled.
>
> Fixes: fd913ef7ce61 ("Bluetooth: btusb: Add out-of-band wakeup support")
> Cc: Rajat Jain <rajatja@google.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/bluetooth/btusb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 5c535f3ab722..4c5344ce16c1 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -3801,7 +3801,7 @@ static int btusb_config_oob_wake(struct hci_dev *hdev)
>         }
>
>         irq_set_status_flags(irq, IRQ_NOAUTOEN);
> -       ret = devm_request_irq(&hdev->dev, irq, btusb_oob_wake_handler,
> +       ret = devm_request_irq(&data->intf->dev, irq, btusb_oob_wake_handler,
>                                0, "OOB Wake-on-BT", data);
>         if (ret) {
>                 bt_dev_err(hdev, "%s: IRQ request failed", __func__);
> --
> 2.52.0

https://sashiko.dev/#/patchset/20260330093311.1621965-1-johan%40kernel.org

Not sure if it is valid though.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: btusb: fix wakeup irq devres lifetime
  2026-03-30 19:17 ` Luiz Augusto von Dentz
@ 2026-04-02  9:35   ` Johan Hovold
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-04-02  9:35 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: Marcel Holtmann, linux-bluetooth, linux-kernel, Rajat Jain

Hi Luiz,

On Mon, Mar 30, 2026 at 03:17:33PM -0400, Luiz Augusto von Dentz wrote:

> On Mon, Mar 30, 2026 at 5:33 AM Johan Hovold <johan@kernel.org> wrote:
> > The OOB wakeup irq is device managed but its lifetime is incorrectly
> > tied to the child HCI device rather than the USB interface to which the
> > driver is bound.
> >
> > This should not cause any trouble currently as the interrupt is only
> > enabled during suspend, but it is technically wrong as the reference
> > counted HCI device could remain after the driver has been unbound.
> >
> > Note that the data passed to the interrupt handler is not device managed
> > and is typically freed before the interrupt during disconnect, but this
> > is also safe as long as the interrupt is disabled.

> https://sashiko.dev/#/patchset/20260330093311.1621965-1-johan%40kernel.org
> 
> Not sure if it is valid though.

I'm afraid it is.

I had missed that the devres behaviour changed in 2023 so that managed
resources are now also released when deregistering a device which has no
driver.

The point about a possible race if disconnecting while suspended is also
valid.

I've just sent a v2 here:

	https://lore.kernel.org/lkml/20260402092704.2346710-1-johan@kernel.org/

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-02  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30  9:33 [PATCH] Bluetooth: btusb: fix wakeup irq devres lifetime Johan Hovold
2026-03-30 19:17 ` Luiz Augusto von Dentz
2026-04-02  9:35   ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox