diff mbox series

Bluetooth: btbcm: Do not free IRQ on close if we did not request it

Message ID 20200427145414.121700-1-hdegoede@redhat.com
State New
Headers show
Series Bluetooth: btbcm: Do not free IRQ on close if we did not request it | expand

Commit Message

Hans de Goede April 27, 2020, 2:54 p.m. UTC
When the patch-ram is missing the hci_bcm code does not request the
IRQ, in this case we should not try to free it from bcm_close()

This fixes the following WARN statements + backtraces:
[  332.670662] WARNING: CPU: 3 PID: 4743 at kernel/irq/devres.c:143 devm_free_irq+0x45/0x50
[  332.670882] Trying to free already-free IRQ 44
[  332.670891] WARNING: CPU: 3 PID: 4743 at kernel/irq/manage.c:1718 free_irq+0x1f4/0x390

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/bluetooth/hci_bcm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 0c34b6c57f7d..0fb4b9c1dfc1 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -118,6 +118,7 @@  struct bcm_device {
 	u32			oper_speed;
 	int			irq;
 	bool			irq_active_low;
+	bool			irq_requested;
 
 #ifdef CONFIG_PM
 	struct hci_uart		*hu;
@@ -333,6 +334,8 @@  static int bcm_request_irq(struct bcm_data *bcm)
 		goto unlock;
 	}
 
+	bdev->irq_requested = true;
+
 	device_init_wakeup(bdev->dev, true);
 
 	pm_runtime_set_autosuspend_delay(bdev->dev,
@@ -514,10 +517,11 @@  static int bcm_close(struct hci_uart *hu)
 	}
 
 	if (bdev) {
-		if (IS_ENABLED(CONFIG_PM) && bdev->irq > 0) {
+		if (bdev->irq_requested) {
 			devm_free_irq(bdev->dev, bdev->irq, bdev);
 			device_init_wakeup(bdev->dev, false);
 			pm_runtime_disable(bdev->dev);
+			bdev->irq_requested = false;
 		}
 
 		err = bcm_gpio_set_power(bdev, false);