Skip to content

Commit 0b67808

Browse files
Wei Yongjungregkh
authored andcommitted
bus: mhi: pci_generic: Fix possible use-after-free in mhi_pci_remove()
This driver's remove path calls del_timer(). However, that function does not wait until the timer handler finishes. This means that the timer handler may still be running after the driver's remove function has finished, which would result in a use-after-free. Fix by calling del_timer_sync(), which makes sure the timer handler has finished, and unable to re-schedule itself. Link: https://lore.kernel.org/r/[email protected] Fixes: 8562d4f ("mhi: pci_generic: Add health-check") Cc: stable <[email protected]> Reported-by: Hulk Robot <[email protected]> Reviewed-by: Hemant kumar <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Loic Poulain <[email protected]> Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c7711c2 commit 0b67808

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/bus/mhi/pci_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ static void mhi_pci_remove(struct pci_dev *pdev)
708708
struct mhi_pci_device *mhi_pdev = pci_get_drvdata(pdev);
709709
struct mhi_controller *mhi_cntrl = &mhi_pdev->mhi_cntrl;
710710

711-
del_timer(&mhi_pdev->health_check_timer);
711+
del_timer_sync(&mhi_pdev->health_check_timer);
712712
cancel_work_sync(&mhi_pdev->recovery_work);
713713

714714
if (test_and_clear_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status)) {

0 commit comments

Comments
 (0)