Return-Path: Message-Id: <766f3c1ba58cf99e0508297ad707df2774aa536a.1515348092.git.lukas@wunner.de> In-Reply-To: References: From: Lukas Wunner Date: Sun, 7 Jan 2018 20:16:32 +0100 Subject: [PATCH v3 04/13] Bluetooth: hci_bcm: Fix race on close MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 To: Marcel Holtmann , Johan Hedberg Cc: Mika Westerberg , Andy Shevchenko , Frederic Danis , Loic Poulain , Hans de Goede , Max Shavrick , Leif Liddy , Daniel Roschka , Ronald Tschalaer , "Peter Y. Chuang" , linux-bluetooth@vger.kernel.org List-ID: Upon ->close, the driver powers the Bluetooth controller down, deasserts the device wake pin, updates the runtime PM status to "suspended" and finally frees the IRQ. Because the IRQ is freed last, a runtime resume can take place after the controller was powered down. The impact is not grave, the worst thing that can happen is that the device wake pin is reasserted (should have no effect while the regulator is off) and that setting the runtime PM status to "suspended" does not reflect reality. Still, it's wrong, so free the IRQ first. Cc: Andy Shevchenko Cc: Frédéric Danis Signed-off-by: Lukas Wunner --- drivers/bluetooth/hci_bcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index c551ef4c350f..6144a3f9c37a 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -372,14 +372,14 @@ static int bcm_close(struct hci_uart *hu) } if (bdev) { - bcm_gpio_set_power(bdev, false); - pm_runtime_disable(bdev->dev); - pm_runtime_set_suspended(bdev->dev); - if (IS_ENABLED(CONFIG_PM) && bdev->irq > 0) { devm_free_irq(bdev->dev, bdev->irq, bdev); device_init_wakeup(bdev->dev, false); } + + bcm_gpio_set_power(bdev, false); + pm_runtime_disable(bdev->dev); + pm_runtime_set_suspended(bdev->dev); } mutex_unlock(&bcm_device_lock); -- 2.15.1