]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
phy: phy-twl4030-usb: Fix possible use-after-free in twl4030_usb_remove()
authorYang Yingliang <yangyingliang@huawei.com>
Wed, 7 Apr 2021 09:27:16 +0000 (17:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:38:17 +0000 (10:38 +0200)
[ Upstream commit e1723d8b87b73ab363256e7ca3af3ddb75855680 ]

This driver's remove path calls cancel_delayed_work(). However, that
function does not wait until the work function finishes. This means
that the callback function may still be running after the driver's
remove function has finished, which would result in a use-after-free.

Fix by calling cancel_delayed_work_sync(), which ensures that
the work is properly cancelled, no longer running, and unable
to re-schedule itself.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20210407092716.3270248-1-yangyingliang@huawei.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/phy/phy-twl4030-usb.c

index f96065a81d1ec6aaeb5ff4fc30401086cdda029f..168780eb29aad3da71ca79ee4d061bfdf01ddaf7 100644 (file)
@@ -753,7 +753,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
 
        usb_remove_phy(&twl->phy);
        pm_runtime_get_sync(twl->dev);
-       cancel_delayed_work(&twl->id_workaround_work);
+       cancel_delayed_work_sync(&twl->id_workaround_work);
        device_remove_file(twl->dev, &dev_attr_vbus);
 
        /* set transceiver mode to power on defaults */