i40e: Cleanup PTP pins on probe failure
Subsystems (3)
PATCH v2 1/1 i40e: Cleanup PTP pins on probe failure
PTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling i40e_ptp_free_pins in the error path.
To support this, i40e_ptp_free_pins is added to the header and pin_config is correctly nullified after being freed.
This has been an issue since i40e_ptp_alloc_pins was introduced.
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e.h +1 -0
@@ -1318,6 +1318,7 @@ void i40e_ptp_restore_hw_time(struct i40e_pf *pf);void i40e_ptp_init (struct i40e_pf *pf);void i40e_ptp_stop (struct i40e_pf *pf);int i40e_ptp_alloc_pins (struct i40e_pf *pf); +void i40e_ptp_free_pins (struct i40e_pf *pf);int i40e_update_adq_vsi_queues (struct i40e_vsi *vsi,int vsi_offset);int i40e_is_vsi_uplink_mode_veb (struct i40e_vsi *vsi);int i40e_get_partition_bw_setting (struct i40e_pf *pf);
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
@@ -16112,6 +16112,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)i40e_clear_interrupt_scheme (pf);kfree (pf->vsi); err_switch_setup: +i40e_ptp_free_pins (pf);i40e_reset_interrupt_capability (pf);timer_shutdown_sync (&pf->service_timer); err_mac_addr:
drivers/net/ethernet/intel/i40e/i40e_ptp.c +2 -1
@@ -940,12 +940,13 @@ int i40e_ptp_hwtstamp_get(struct net_device *netdev,* * Release memory allocated for PTP pins. **/ -static void i40e_ptp_free_pins (struct i40e_pf *pf) +void i40e_ptp_free_pins (struct i40e_pf *pf) {if (i40e_is_ptp_pin_dev (&pf->hw)) {kfree (pf->ptp_pins);kfree (pf->ptp_caps.pin_config); pf->ptp_pins =NULL ; + pf->ptp_caps.pin_config =NULL ; } }
Signature · 5 lines
2.43.0 v2: * No need to guard kfree of NULL * Followed Dawid's instructions re: target tree, Cc, changelog
Dear Matt,
Thank you for the patch. Should you resend you could spell the verb *clean up* with a space:
Quoted 1 line
i40e: Clean PTP pins up on probe failure
or
Quoted 1 line
i40e: Clean up PTP pins on probe failure
But it’s not important.
Am 07.04.26 um 18:14 schrieb Matt Vollrath:
Quoted 51 lines
PTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling
i40e_ptp_free_pinsin the error path.To support this,
i40e_ptp_free_pinsis added to the header andpin_configis correctly nullified after being freed.This has been an issue since
i40e_ptp_alloc_pinswas introduced.Fixes 1050713026a08 ("i40e: add support for PTP external synchronization clock")Reported-by Kohei Enju <[email protected]>Signed-off-by Matt Vollrath <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/i40e/i40e.h +1
-0@@ -1318,6 +1318,7 @@ void i40e_ptp_restore_hw_time(struct i40e_pf *pf);void i40e_ptp_init (struct i40e_pf *pf);void i40e_ptp_stop (struct i40e_pf *pf);int i40e_ptp_alloc_pins (struct i40e_pf *pf); +void i40e_ptp_free_pins (struct i40e_pf *pf);int i40e_update_adq_vsi_queues (struct i40e_vsi *vsi,int vsi_offset);int i40e_is_vsi_uplink_mode_veb (struct i40e_vsi *vsi);int i40e_get_partition_bw_setting (struct i40e_pf *pf);drivers/net/ethernet/intel/i40e/i40e_main.c +1
-0@@ -16112,6 +16112,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)i40e_clear_interrupt_scheme (pf);kfree (pf->vsi); err_switch_setup: +i40e_ptp_free_pins (pf);i40e_reset_interrupt_capability (pf);timer_shutdown_sync (&pf->service_timer); err_mac_addr:drivers/net/ethernet/intel/i40e/i40e_ptp.c +0
-0@@ -940,12 +940,13 @@ int i40e_ptp_hwtstamp_get(struct net_device *netdev,* * Release memory allocated for PTP pins. **/
drivers/net/ethernet/intel/i40e/i40e_ptp.c int i40e_ptp_hwtstamp_get(struct net_device *netdev, · line 951
Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_ptp.c +2
-1-static void i40e_ptp_free_pins (struct i40e_pf *pf) +void i40e_ptp_free_pins (struct i40e_pf *pf) {if (i40e_is_ptp_pin_dev (&pf->hw)) {kfree (pf->ptp_pins);kfree (pf->ptp_caps.pin_config); pf->ptp_pins =NULL ; + pf->ptp_caps.pin_config =NULL ; } }
Kind regards,
Paul
Quoted 83 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Matt Vollrath
Sent: Tuesday, April 7, 2026 6:15 PM
To: [email protected]
Cc: Matt Vollrath <[email protected]>; Kohei Enju <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net v2] i40e: Cleanup PTP pins on probe failurePTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling
i40e_ptp_free_pinsin the error path.To support this,
i40e_ptp_free_pinsis added to the header andpin_configis correctly nullified after being freed.This has been an issue since
i40e_ptp_alloc_pinswas introduced.Fixes 1050713026a08 ("i40e: add support for PTP externalsynchronization clock")
Reported-by Kohei Enju <[email protected]>Signed-off-by Matt Vollrath <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)drivers/net/ethernet/intel/i40e/i40e.h +0
-0@@ -1318,6 +1318,7 @@ void i40e_ptp_restore_hw_time(struct i40e_pf *pf); void i40e_ptp_init(struct i40e_pf *pf); void
i40e_ptp_stop(struct i40e_pf *pf); inti40e_ptp_alloc_pins(struct i40e_pf *pf);
+voidi40e_ptp_free_pins(struct i40e_pf *pf);
inti40e_update_adq_vsi_queues(struct i40e_vsi *vsi, int vsi_offset);
inti40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi); inti40e_get_partition_bw_setting(struct i40e_pf *pf); diff --gita/drivers/net/ethernet/intel/i40e/i40e_main.cb/drivers/net/ethernet/intel/i40e/i40e_main.c
index926d001b2150..c7062aa476dd100644drivers/net/ethernet/intel/i40e/i40e_main.c +1
-0@@ -16112,6 +16112,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)i40e_clear_interrupt_scheme (pf );kfree (pf->vsi); err_switch_setup: +i40e_ptp_free_pins (pf);i40e_reset_interrupt_capability (pf);timer_shutdown_sync (&pf->service_timer);
err_mac_addr:drivers/net/ethernet/intel/i40e/i40e_ptp.c +2
-2@@ -940,12 +940,13 @@ int i40e_ptp_hwtstamp_get(struct net_device*netdev, * * Release memory allocated for PTP pins. **/ -static void i40e_ptp_free_pins (struct i40e_pf *pf) +void i40e_ptp_free_pins (struct i40e_pf *pf) {if (i40e_is_ptp_pin_dev (&pf->hw)) {kfree (pf->ptp_pins);kfree (pf->ptp_caps.pin_config); pf->ptp_pins =NULL ; + pf->ptp_caps.pin_config =NULL ; } } --2.43.0
Quoted 3 lines
v2:
* No need to guard kfree of NULL
* Followed Dawid's instructions re: target tree, Cc, changelog
Quoted 7 lines · Matt Vollrath
PTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling
i40e_ptp_free_pinsin the error path.To support this,
i40e_ptp_free_pinsis added to the header andpin_configis correctly nullified after being freed.
Quoted 6 lines
This has been an issue since
i40e_ptp_alloc_pinswas introduced.Fixes 1050713026a08 ("i40e: add support for PTP external synchronization clock")Reported-by Kohei Enju <[email protected]>Signed-off-by Matt Vollrath <[email protected]>
Thanks for updating from v1.
Quoted 7 lines · Matt Vollrath
PTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling
i40e_ptp_free_pinsin the error path.To support this,
i40e_ptp_free_pinsis added to the header andpin_configis correctly nullified after being freed.
Quoted 7 lines
This has been an issue since
i40e_ptp_alloc_pinswas introduced.Fixes 1050713026a08 ("i40e: add support for PTP external synchronization clock")Reported-by Kohei Enju <[email protected]>Signed-off-by Matt Vollrath <[email protected]>---
Hey Matt,
I wrote a comment on your "[PATCH iwl-net v2] e1000e: Unroll PTP in probe error handling" submission about the changelog positioning and CCing stable.
For this patch right here I see the Cc: tag is added correctly to the commit msg body, but the changelog is inserted in the same way as in the submission I mentioned above.
Not a blocker by any means, but just wanted to let you know for future submissions to take this into account.
Thanks
~Dawid
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Matt Vollrath
Sent: Tuesday, April 7, 2026 9:15 AM
To: [email protected]
Cc: Matt Vollrath <[email protected]>; Kohei Enju <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net v2] i40e: Cleanup PTP pins on probe failurePTP pin structs are allocated early in probe, but never cleaned up.
Fix this by calling
i40e_ptp_free_pinsin the error path.To support this,
i40e_ptp_free_pinsis added to the header andpin_configis correctly nullified after being freed.This has been an issue since
i40e_ptp_alloc_pinswas introduced.Fixes 1050713026a08 ("i40e: add support for PTP external synchronization clock")Reported-by Kohei Enju <[email protected]>Signed-off-by Matt Vollrath <[email protected]>
Quoted 5 lines
--- drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)