aq_nic_start() requests the PTP IRQ before it finishes the rest of the NIC startup sequence. A later startup failure reaches aq_nic_stop(), which calls aq_ptp_irq_free() even when aq_ptp_irq_alloc() skipped request_irq() or when request_irq() failed. Track whether the PTP IRQ request succeeded. Only call free_irq() after a matching request_irq(). Fixes: 04a1839950d9 ("net: aquantia: implement data PTP datapath") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Runyu Xiao --- drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c index 558ac9237..a5b69f1c7 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c @@ -84,6 +84,7 @@ struct aq_ptp_s { struct ptp_tx_timeout ptp_tx_timeout; unsigned int idx_ptp_vector; + bool irq_allocated; struct napi_struct napi; struct aq_ring_s ptp_tx; @@ -1033,6 +1034,8 @@ int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic) if (pdev->msix_enabled || pdev->msi_enabled) { err = request_irq(pci_irq_vector(pdev, aq_ptp->idx_ptp_vector), aq_ptp_isr, 0, aq_nic->ndev->name, aq_ptp); + if (!err) + aq_ptp->irq_allocated = true; } else { err = -EINVAL; goto err_exit; @@ -1050,7 +1053,11 @@ void aq_ptp_irq_free(struct aq_nic_s *aq_nic) if (!aq_ptp) return; + if (!aq_ptp->irq_allocated) + return; + free_irq(pci_irq_vector(pdev, aq_ptp->idx_ptp_vector), aq_ptp); + aq_ptp->irq_allocated = false; } int aq_ptp_ring_init(struct aq_nic_s *aq_nic) -- 2.34.1