Skip to contentSkip to conversation

ice: fix infinite recursion in ice_cfg_tx_topo via ice_init_dev_hw

PATCH In review Petr Oros 7 participants 10 messages Apr 13 – Apr 23

Subsystems (3)
lore
Share & tools
lore

Petr Oros

author
#0 lore raw

PATCH 1/1 ice: fix infinite recursion in ice_cfg_tx_topo via ice_init_dev_hw

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
---
 drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 ++
 drivers/net/ethernet/intel/ice/ice_common.c      | 2 --
 drivers/net/ethernet/intel/ice/ice_main.c        | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +2 -0
index 6144cee8034d77..641d6e289d5ce6 100644
@@ -1245,6 +1245,8 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)
 		return err;
 	}
 
+	ice_init_dev_hw(pf);
+
 	/* load MSI-X values */
 	ice_set_min_max_msix(pf);
 
drivers/net/ethernet/intel/ice/ice_common.c +0 -2
index ce11fea122d03e..b617a6bff89134 100644
@@ -1126,8 +1126,6 @@ int ice_init_hw(struct ice_hw *hw)
 	if (status)
 		goto err_unroll_fltr_mgmt_struct;
 
-	ice_init_dev_hw(hw->back);
-
 	mutex_init(&hw->tnl_lock);
 	ice_init_chk_recipe_reuse_support(hw);
 
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
index e2a5534819d194..a27be29f9bbbfc 100644
@@ -5314,6 +5314,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 		return err;
 	}
 
+	ice_init_dev_hw(pf);
+
 	adapter = ice_adapter_get(pdev);
 	if (IS_ERR(adapter)) {
 		err = PTR_ERR(adapter);
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw

Dear Petr,

Thank you very much for your patch.

Am 13.04.26 um 21:14 schrieb Petr Oros:

Quoted 76 lines

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
---
  drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 ++
  drivers/net/ethernet/intel/ice/ice_common.c      | 2 --
  drivers/net/ethernet/intel/ice/ice_main.c        | 2 ++
  3 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +2 -0
index 6144cee8034d77..641d6e289d5ce6 100644
@@ -1245,6 +1245,8 @@ static int ice_devlink_reinit_up(struct ice_pf *pf)
  		return err;
  	}
 
+	ice_init_dev_hw(pf);
+
  	/* load MSI-X values */
  	ice_set_min_max_msix(pf);
 
drivers/net/ethernet/intel/ice/ice_common.c +0 -2
index ce11fea122d03e..b617a6bff89134 100644
@@ -1126,8 +1126,6 @@ int ice_init_hw(struct ice_hw *hw)
  	if (status)
  		goto err_unroll_fltr_mgmt_struct;
 
-	ice_init_dev_hw(hw->back);
-
  	mutex_init(&hw->tnl_lock);
  	ice_init_chk_recipe_reuse_support(hw);
 
drivers/net/ethernet/intel/ice/ice_main.c +0 -0
index e2a5534819d194..a27be29f9bbbfc 100644

drivers/net/ethernet/intel/ice/ice_main.c ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) · line 5321

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
@@ -5314,6 +5314,8 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
  		return err;
  	}
 
+	ice_init_dev_hw(pf);
+
  	adapter = ice_adapter_get(pdev);
  	if (IS_ERR(adapter)) {
  		err = PTR_ERR(adapter);

Kind regards,

Paul

Reviewed-by on v1 1/1
#2 lore raw
In reply to Petr Oros
Quoted 17 lines · Petr Oros

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

Quoted 9 lines

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Oof, ya thats not good. I guess this only happens if the topology needs to change, so it wouldn't affect many systems where we had already changed the topology before hand on the old driver.

Quoted 6 lines

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

Quoted 7 lines

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")

The fix looks correct to me, and definitely the most elegant.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Petr Oros
Quoted 112 lines

-----Original Message-----
From: Petr Oros <[email protected]>
Sent: Monday, April 13, 2026 9:14 PM
To: [email protected]
Cc: Oros, Petr <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Loktionov, Aleksandr <[email protected]>; Nikolay Aleksandrov <[email protected]>; Daniel Zahka <[email protected]>; Greenwalt, Paul <[email protected]>; Ertman, David M <[email protected]>; Michal Swiatkowski <[email protected]>; Keller, Jacob E <[email protected]>; [email protected]; linux- [email protected]
Subject: [PATCH iwl-net] ice: fix infinite recursion in ice_cfg_tx_topo via ice_init_dev_hw

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit

paths")

---
 drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 ++
 drivers/net/ethernet/intel/ice/ice_common.c      | 2 --
 drivers/net/ethernet/intel/ice/ice_main.c        | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/devlink/devlink.c +2 -0
index 6144cee8034d77..641d6e289d5ce6 100644
@@ -1245,6 +1245,8 @@ static int ice_devlink_reinit_up(struct ice_pf
 *pf)
 		return err;
 	}
 
+	ice_init_dev_hw(pf);
+
 	/* load MSI-X values */
 	ice_set_min_max_msix(pf);
drivers/net/ethernet/intel/ice/ice_common.c +0 -2
index ce11fea122d03e..b617a6bff89134 100644
@@ -1126,8 +1126,6 @@ int ice_init_hw(struct ice_hw *hw)
 	if (status)
 		goto err_unroll_fltr_mgmt_struct;
 
-	ice_init_dev_hw(hw->back);
-
 	mutex_init(&hw->tnl_lock);
 	ice_init_chk_recipe_reuse_support(hw);
 
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
index e2a5534819d194..a27be29f9bbbfc 100644
@@ -5314,6 +5314,8 @@ ice_probe(struct pci_dev *pdev, const struct
 pci_device_id __always_unused *ent)
 		return err;
 	}
 
+	ice_init_dev_hw(pf);
+
 	adapter = ice_adapter_get(pdev);
 	if (IS_ERR(adapter)) {
Quoted 3 lines

err = PTR_ERR(adapter);
--
2.52.0

reviewer
#4 lore raw
In reply to Petr Oros
Quoted 32 lines · Petr Oros

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

Quoted 7 lines

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")

Hi Petr,

I don't intended to delay this patch.
But could you follow-up by looking over the AI generated review of this patch on sashiko.dev?

Thanks!

#5 lore raw
Quoted 41 lines · Simon Horman
Quoted 32 lines · Petr Oros

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

Quoted 7 lines

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
Quoted 7 lines

Hi Petr,

I don't intended to delay this patch.
But could you follow-up by looking over the AI generated review of this patch on sashiko.dev?

Thanks!

I'll take a look as well. I recently included this fix in Intel Wired LAN update last night, so hopefully nothing too problematic...

Sashiko says:

Quoted 5 lines

While this code wasn't introduced by this patch, the restructuring makes it more visible: can this cause a use-after-free if the nested hardware initialization fails?
If ice_cfg_tx_topo() triggers a topology change, it performs a CORER reset followed by an unroll (ice_deinit_hw) and re-initialization (ice_init_hw). If

Quoted 8 lines

that nested ice_init_hw() fails, its unroll path frees hw->port_info and destroys control queues and mutexes.
Because ice_init_dev_hw() returns void, it swallows the -ENODEV error and falls back to safe mode. This allows ice_probe() to proceed with an unrolled and freed hardware struct, which would result in a use-after-free when memory like hw->port_info is accessed later.
Should ice_init_dev_hw() be updated to return an error code so the caller can abort the probe when base hardware unrolls occur?

I think this suggestion might be good. We fail in probe if ice_init_hw() fails regardless of "safe" mode, so having init_dev_hw() also fail if the reinit fails makes some sense to me...

Thanks,
Jake

#6 lore raw
Quoted 3 lines · Jacob Keller

I'll take a look as well. I recently included this fix in Intel Wired LAN update last night, so hopefully nothing too problematic...

Correction, and I need more caffeine: I think I had considered including this fix but didn't quite make the cut last night when sending.

maintainer Reviewed-by
#7 lore raw
In reply to Jacob Keller
Quoted 28 lines · Jacob Keller
Quoted 27 lines · Simon Horman
Quoted 26 lines · Petr Oros

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw()

ice_cfg_tx_topo() stops calling ice_init_dev_hw(), that is the real change that patch does, OK

Quoted 17 lines
Quoted 17 lines
Quoted 10 lines

during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")

Hi Petr,

I don't intended to delay this patch.
But could you follow-up by looking over the AI generated review of this patch on sashiko.dev?

Quoted 14 lines
Quoted 1 line

Thanks!

I'll take a look as well. I recently included this fix in Intel Wired LAN update last night, so hopefully nothing too problematic...

Sashiko says:

Quoted 7 lines

While this code wasn't introduced by this patch, the restructuring makes it more visible: can this cause a use-after-free if the nested hardware initialization fails?
If ice_cfg_tx_topo() triggers a topology change, it performs a CORER reset followed by an unroll (ice_deinit_hw) and re-initialization (ice_init_hw). If that nested ice_init_hw() fails, its unroll path frees hw->port_info and destroys control queues and mutexes.

here is a talk about "prerequisite for the problem"

Quoted 1 line
Quoted 1 line

Because ice_init_dev_hw() returns void, it swallows the -ENODEV error and

and here is about code that Petr just removes, IOW, does not apply

Plausible sounding comments, yeah, I hope we will not drown in the sea of AI content :(

for the patch:
I have tested that it does not break my test suite (it was me to start touching ice_init_hw() and friends), and both code and human written commit message looks good,

thank you for fixing the code after me!

author
#8 lore raw
In reply to Simon Horman
Quoted 40 lines · Simon Horman
Quoted 32 lines · Petr Oros

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

Quoted 7 lines

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
Quoted 8 lines

Hi Petr,

I don't intended to delay this patch.
But could you follow-up by looking over the AI generated review of this patch on sashiko.dev?

Thanks!

Hi Simon,

Thanks, the sashiko.dev concern is valid. ice_init_dev_hw() swallowing -ENODEV from the torn-down hw is a latent UAF independent of the recursion fix here. I will send a follow-up patch that propagates -ENODEV to abort probe cleanly.

Regards,
Petr

Tested-by on v1 1/1
#9 lore raw
In reply to Petr Oros
Quoted 32 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Petr Oros
Sent: Monday, April 13, 2026 12:14 PM
To: [email protected]
Cc: Michal Swiatkowski <[email protected]>; Greenwalt, Paul <[email protected]>; Daniel Zahka <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Nikolay Aleksandrov <[email protected]>; Eric Dumazet <[email protected]>; linux- [email protected]; Loktionov, Aleksandr <[email protected]>; Andrew Lunn <[email protected]>; Nguyen, Anthony L <[email protected]>; Ertman, David M <[email protected]>; Keller, Jacob E <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; David S. Miller <[email protected]>; [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net] ice: fix infinite recursion in ice_cfg_tx_topo via ice_init_dev_hw

On certain E810 configurations where firmware supports Tx scheduler topology switching (tx_sched_topo_comp_mode_en), ice_cfg_tx_topo() may need to apply a new 5-layer or 9-layer topology from the DDP package. If the AQ command to set the topology fails (e.g. due to invalid DDP data or firmware limitations), the global configuration lock must still be cleared via a CORER reset.

Commit 86aae43f21cf ("ice: don't leave device non-functional if Tx scheduler config fails") correctly fixed this by refactoring ice_cfg_tx_topo() to always trigger CORER after acquiring the global lock and re-initialize hardware via ice_init_hw() afterwards.

However, commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths") later moved ice_init_dev_hw() into ice_init_hw(), breaking the reinit path introduced by 86aae43f21cf. This creates an infinite recursive call chain:

ice_init_hw()
ice_init_dev_hw()
ice_cfg_tx_topo() # topology change needed
ice_deinit_hw()
ice_init_hw() # reinit after CORER
ice_init_dev_hw() # recurse
ice_cfg_tx_topo()
... # stack overflow

Fix by moving ice_init_dev_hw() back out of ice_init_hw() and calling it explicitly from ice_probe() and ice_devlink_reinit_up(). The third caller, ice_cfg_tx_topo(), intentionally does not need ice_init_dev_hw() during its reinit, it only needs the core HW reinitialization. This breaks the recursion cleanly without adding flags or guards.

The deinit ordering changes from commit 8a37f9e2ff40 ("ice: move
ice_deinit_dev() to the end of deinit paths") which fixed slow rmmod are preserved, only the init-side placement of ice_init_dev_hw() is reverted.

Quoted 7 lines
Fixes 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
---
 drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 ++
 drivers/net/ethernet/intel/ice/ice_common.c      | 2 --
 drivers/net/ethernet/intel/ice/ice_main.c        | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)