Skip to contentSkip to conversation

i40e: Cleanup PTP registration on probe failure

PATCH In review Matt Vollrath 4 participants 5 messages Apr 6 – Apr 24

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i40e: Cleanup PTP registration on probe failure

Fix two conditions which would leak PTP registration on probe failure:

1. i40e_setup_pf_switch can encounter an error in i40e_setup_pf_filter_control, call i40e_ptp_init, then return non-zero, sending i40e_probe to err_vsis.

2. i40e_setup_misc_vector can return non-zero, sending i40e_probe to err_vsis.

Both of these conditions have been present since PTP was introduced in this driver.

Found with coccinelle.

Fixes beb0dff1251db ("i40e: enable PTP")
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
index 926d001b2150..f3de147aaddf 100644
@@ -16109,6 +16109,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	/* Unwind what we've done if something failed in the setup */
 err_vsis:
 	set_bit(__I40E_DOWN, pf->state);
+	i40e_ptp_stop(pf);
 	i40e_clear_interrupt_scheme(pf);
 	kfree(pf->vsi);
 err_switch_setup:
Signature · 1 line
2.43.0
#1 lore raw

On 2026-04-06 2:58 AM, Matt Vollrath wrote:

Hey Matt,

Thanks for the patch!

Quoted 9 lines

Fix two conditions which would leak PTP registration on probe failure:

1. i40e_setup_pf_switch can encounter an error in i40e_setup_pf_filter_control, call i40e_ptp_init, then return non-zero, sending i40e_probe to err_vsis.

2. i40e_setup_misc_vector can return non-zero, sending i40e_probe to err_vsis.

Quoted 8 lines

Both of these conditions have been present since PTP was introduced in this driver.

Found with coccinelle.

Fixes beb0dff1251db ("i40e: enable PTP")

---

In the future when sending to Intel-wired-lan (IWL) you should use either the iwl-net or iwl-next as the target tree, example based on this patch:
[PATCH iwl-net v2] i40e: Cleanup PTP registration on probe failure

iwl-net is for fixes (such as this patch), iwl-next for new features / refactors that don't need to be backported to stable kernels.

Given this is a fix you could also add in the commit msg:
Cc: [email protected]

that way it will be automatically picked up for backporting to currently maintained stable kernel versions by the -stable maintainers [1].

For future submissions, if you send a v2/v3/vX... you should put a changelog here of what has changed w.r.t. the previous revision. An example in this case:

v2:
* add Fixes tag
* change name of patch:

	i40e: Cleanup PTP upon probe failure -> i40e: Cleanup PTP registration 

on probe failure

The important bit is to do include the changelog below the '---', that way it will be disregarded by e.g. 'git am' and won't pollute the commit msg. Changelog is for reviewers only to quickly assess what to look for / what has changed :)

drivers/net/ethernet/intel/i40e/i40e_main.c static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 16112

Quoted 12 lines
  drivers/net/ethernet/intel/i40e/i40e_main.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
index 926d001b2150..f3de147aaddf 100644
@@ -16109,6 +16109,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  	/* Unwind what we've done if something failed in the setup */
  err_vsis:
  	set_bit(__I40E_DOWN, pf->state);
+	i40e_ptp_stop(pf);

As for the change itself I'm not a PTP expert but will try to ping someone internally to review your patch.

Thanks
~Dawid

[1] https://docs.kernel.org/process/stable-kernel-rules.html#option-1

Quoted 3 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
  	i40e_clear_interrupt_scheme(pf);
  	kfree(pf->vsi);
  err_switch_setup:
#2 lore raw
Quoted 10 lines · Dawid Osuchowski

In the future when sending to Intel-wired-lan (IWL) you should use either the iwl-net or iwl-next as the target tree, example based on this patch:
    [PATCH iwl-net v2] i40e: Cleanup PTP registration on probe failure

iwl-net is for fixes (such as this patch), iwl-next for new features / refactors that don't need to be backported to stable kernels.

Given this is a fix you could also add in the commit msg:
    Cc: [email protected]

that way it will be automatically picked up for backporting to currently maintained stable kernel versions by the -stable maintainers [1].

Quoted 8 lines

For future submissions, if you send a v2/v3/vX... you should put a changelog here of what has changed w.r.t. the previous revision. An example in this case:

v2:
* add Fixes tag
* change name of patch:
    i40e: Cleanup PTP upon probe failure -> i40e: Cleanup PTP registration on probe failure

The important bit is to do include the changelog below the '---', that way it will be disregarded by e.g. 'git am' and won't pollute the commit msg. Changelog is for reviewers only to quickly assess what to look for / what has changed :)

Thanks Dawid, I'll do that.
mv

Tested-by on v2 1/1
#3 lore raw
In reply to Matt Vollrath
Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Matt Vollrath
Sent: Sunday, April 5, 2026 5:59 PM
To: [email protected]
Cc: Matt Vollrath <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2] i40e: Cleanup PTP registration on probe failure

Fix two conditions which would leak PTP registration on probe failure:

1. i40e_setup_pf_switch can encounter an error in i40e_setup_pf_filter_control, call i40e_ptp_init, then return non-zero, sending i40e_probe to err_vsis.

2. i40e_setup_misc_vector can return non-zero, sending i40e_probe to err_vsis.

Both of these conditions have been present since PTP was introduced in this driver.

Quoted 7 lines

Found with coccinelle.

Fixes beb0dff1251db ("i40e: enable PTP")
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 1 +
 1 file changed, 1 insertion(+)
Reviewed-by on v2 1/1
#4 lore raw
In reply to Matt Vollrath
Quoted 44 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Matt Vollrath
Sent: Monday, April 6, 2026 2:59 AM
To: [email protected]
Cc: Matt Vollrath <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2] i40e: Cleanup PTP registration on probe failure

Fix two conditions which would leak PTP registration on probe failure:

1. i40e_setup_pf_switch can encounter an error in i40e_setup_pf_filter_control, call i40e_ptp_init, then return non-zero, sending i40e_probe to err_vsis.

2. i40e_setup_misc_vector can return non-zero, sending i40e_probe to err_vsis.

Both of these conditions have been present since PTP was introduced in this driver.

Found with coccinelle.

Fixes beb0dff1251db ("i40e: enable PTP")
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
index 926d001b2150..f3de147aaddf 100644
@@ -16109,6 +16109,7 @@ static int i40e_probe(struct pci_dev *pdev,
 const struct pci_device_id *ent)
 	/* Unwind what we've done if something failed in the setup */
 err_vsis:
 	set_bit(__I40E_DOWN, pf->state);
+	i40e_ptp_stop(pf);
 	i40e_clear_interrupt_scheme(pf);
 	kfree(pf->vsi);
Quoted 3 lines

err_switch_setup:
--
2.43.0