]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
Bluetooth: btsdio: fix use after free bug in btsdio_remove due to race condition
authorZheng Wang <zyytlz.wz@163.com>
Wed, 8 Mar 2023 16:45:01 +0000 (00:45 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 10 Apr 2023 17:23:01 +0000 (10:23 -0700)
In btsdio_probe, the data->work is bound with btsdio_work. It will be
started in btsdio_send_frame.

If the btsdio_remove runs with a unfinished work, there may be a race
condition that hdev is freed but used in btsdio_work. Fix it by
canceling the work before do cleanup in btsdio_remove.

Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btsdio.c

index 02893600db390402858ebf65618832f79cadc375..51000320e1ea89442af6a46d03974749e9f80fed 100644 (file)
@@ -358,6 +358,7 @@ static void btsdio_remove(struct sdio_func *func)
        if (!data)
                return;
 
+       cancel_work_sync(&data->work);
        hdev = data->hdev;
 
        sdio_set_drvdata(func, NULL);