Re: [PATCH net v2 2/2] net: fec: free the PPS interrupt before tearing down the PHC and netdev

From: Bui Duc Phuc

Date: Tue Sep 08 2026 - 07:12:41 EST


> @@ -861,6 +865,12 @@ void fec_ptp_stop(struct platform_device *pdev)
>
> cancel_delayed_work_sync(&fep->time_keep);
> hrtimer_cancel(&fep->perout_timer);
> +
> + if (fep->pps_irq >= 0) {
> + devm_free_irq(&pdev->dev, fep->pps_irq, ndev);
> + fep->pps_irq = -1;
> + }
> +

I noticed that fec_ptp_stop(pdev) is called only from the failed_init
error path in fec_probe():

failed_init:
fec_ptp_stop(pdev);
failed_reset:
...
failed_ioremap:
free_netdev(ndev);

There are several other error paths below failed_init that eventually
reach free_netdev(ndev) without calling fec_ptp_stop().

Since fec_ptp_stop() is currently responsible for calling
devm_free_irq(&pdev->dev, fep->pps_irq, ndev),
could this result in a use-after-free if the PPS IRQ has already been
registered and one of these lower error paths is taken?

Would it make more sense to handle the PPS IRQ cleanup separately on
these error paths, or,
use a devm-based approach so that the IRQ lifetime is managed automatically?