From d96ff7ccd94334aca6f5b4a7daeb6cd91e340193 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 3 Apr 2023 16:53:16 +0900 Subject: [PATCH] bcmdhd: fix possible deadlock during dhdsdio_probe() andn dhdsdio_release() Not only during probe but also during release, there is lock inversion. Remove those lock inversions to fix possible deadlock. Note: during dhdsdio_probe(), there is still lock inversion missed from the commit cd03083b2410 ("bcmdhd: fix possible deadlock during dhdsdio_probe()"). Change-Id: I8c1fb82c3ebaa7ccf58c1e01c94b1d005df42179 Signed-off-by: Seung-Woo Kim --- drivers/net/wireless/bcmdhd/dhd_sdio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/bcmdhd/dhd_sdio.c b/drivers/net/wireless/bcmdhd/dhd_sdio.c index ac63813..1dc3125 100644 --- a/drivers/net/wireless/bcmdhd/dhd_sdio.c +++ b/drivers/net/wireless/bcmdhd/dhd_sdio.c @@ -7772,11 +7772,17 @@ dhdsdio_probe(uint16 venid, uint16 devid, uint16 bus_no, uint16 slot, goto fail; } + DHD_MUTEX_UNLOCK(); + /* Attach to the dhd/OS/network interface */ if (!(bus->dhd = dhd_attach(osh, bus, SDPCM_RESERVE))) { DHD_ERROR(("%s: dhd_attach failed\n", __FUNCTION__)); + DHD_MUTEX_LOCK(); goto fail; } + + DHD_MUTEX_LOCK(); + #if defined(BT_OVER_SDIO) g_dhd_pub = bus->dhd; DHD_ERROR(("%s: g_dhd_pub %p\n", __FUNCTION__, g_dhd_pub)); @@ -8399,7 +8405,9 @@ dhdsdio_release(dhd_bus_t *bus, osl_t *osh) if (bus->dhd) { dongle_isolation = bus->dhd->dongle_isolation; + DHD_MUTEX_UNLOCK(); dhd_detach(bus->dhd); + DHD_MUTEX_LOCK(); } /* De-register interrupt handler */ -- 2.7.4