Re: [PATCH] PCI: switchtec: Fix use-after-free in switchtec_pci_remove due to race condition
From: Logan Gunthorpe
Date: Wed Aug 05 2026 - 12:12:59 EST
On 2026-08-04 19:28, Pei Xiao wrote:
>> I'm wondering if these should come before the mrpc_timeout sync.
>> Otherwise, hypothetically, new work could be added and another timeout
>> could be in progress.
>>
> yes,
>
> + cancel_work_sync(&stdev->mrpc_work);
> + cancel_work_sync(&stdev->link_event_work);
> cancel_delayed_work_sync(&stdev->mrpc_timeout);
>
>> Also, I'm not sure, but seems like the interrupt should be disabled
>> before this as well?
> I looked it up and it appears that pci_clear_master cannot disable
> interrupt enabling. Should I use devm_free_irq?
Yes, I believe a couple calls to devm_free_irq() is what will be needed
here.
Logan