bcmdhd: fix possible deadlock during dhdsdio_probe() andn dhdsdio_release() 86/290786/3 accepted/tizen/unified/20230404.140026
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 3 Apr 2023 07:53:16 +0000 (16:53 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 3 Apr 2023 09:19:14 +0000 (18:19 +0900)
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 <sw0312.kim@samsung.com>
drivers/net/wireless/bcmdhd/dhd_sdio.c

index ac63813..1dc3125 100644 (file)
@@ -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 */