Skip to content

Commit a275432

Browse files
mvollrathgregkh
authored andcommitted
i40e: Cleanup PTP pins on probe failure
commit 678b713 upstream. 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. Fixes: 1050713 ("i40e: add support for PTP external synchronization clock") Reported-by: Kohei Enju <kohei@enjuk.jp> Cc: stable@vger.kernel.org Signed-off-by: Matt Vollrath <tactii@gmail.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Reviewed-by: Kohei Enju <kohei@enjuk.jp> Tested-by: Sunitha Mekala <sunithax.d.mekala@intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20260506-jk-iwl-net-2026-05-04-v2-2-a5ea4dc837a9@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 265ac26 commit a275432

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ void i40e_ptp_restore_hw_time(struct i40e_pf *pf);
13101310
void i40e_ptp_init(struct i40e_pf *pf);
13111311
void i40e_ptp_stop(struct i40e_pf *pf);
13121312
int i40e_ptp_alloc_pins(struct i40e_pf *pf);
1313+
void i40e_ptp_free_pins(struct i40e_pf *pf);
13131314
int i40e_update_adq_vsi_queues(struct i40e_vsi *vsi, int vsi_offset);
13141315
int i40e_is_vsi_uplink_mode_veb(struct i40e_vsi *vsi);
13151316
int i40e_get_partition_bw_setting(struct i40e_pf *pf);

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16226,6 +16226,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1622616226
i40e_clear_interrupt_scheme(pf);
1622716227
kfree(pf->vsi);
1622816228
err_switch_setup:
16229+
i40e_ptp_free_pins(pf);
1622916230
i40e_reset_interrupt_capability(pf);
1623016231
timer_shutdown_sync(&pf->service_timer);
1623116232
err_mac_addr:

drivers/net/ethernet/intel/i40e/i40e_ptp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,13 @@ int i40e_ptp_get_ts_config(struct i40e_pf *pf, struct ifreq *ifr)
937937
*
938938
* Release memory allocated for PTP pins.
939939
**/
940-
static void i40e_ptp_free_pins(struct i40e_pf *pf)
940+
void i40e_ptp_free_pins(struct i40e_pf *pf)
941941
{
942942
if (i40e_is_ptp_pin_dev(&pf->hw)) {
943943
kfree(pf->ptp_pins);
944944
kfree(pf->ptp_caps.pin_config);
945945
pf->ptp_pins = NULL;
946+
pf->ptp_caps.pin_config = NULL;
946947
}
947948
}
948949

0 commit comments

Comments
 (0)