From: Zheng Wang Date: Thu, 9 Mar 2023 08:07:39 +0000 (+0800) Subject: Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work X-Git-Tag: v6.3-rc4~28^2~1^2~2 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1e9ac114c442;p=linux-block.git Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work In btsdio_probe, &data->work was bound with btsdio_work.In btsdio_send_frame, it was started by schedule_work. If we call btsdio_remove with an unfinished job, there may be a race condition and cause UAF bug on hdev. Fixes: ddbaf13e3609 ("[Bluetooth] Add generic driver for Bluetooth SDIO devices") Signed-off-by: Zheng Wang Signed-off-by: Luiz Augusto von Dentz --- diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index 795be33f2892..02893600db39 100644 --- a/drivers/bluetooth/btsdio.c +++ b/drivers/bluetooth/btsdio.c @@ -354,6 +354,7 @@ static void btsdio_remove(struct sdio_func *func) BT_DBG("func %p", func); + cancel_work_sync(&data->work); if (!data) return;