Skip to contentSkip to conversation

ice: fix devlink reload call trace

PATCH In review Paul Greenwalt 3 participants 3 messages Dec 29, 2025 – Jan 16

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

PATCH 1/1 ice: fix devlink reload call trace

Commit 4da71a77fc3b ("ice: read internal temperature sensor") introduced internal temperature sensor reading via HWMON. ice_hwmon_init() was added to ice_init_feature() and ice_hwmon_exit() was added to ice_remove(). As a result if devlink reload is used to reinit the device and then the driver is removed, a call trace can occur.

BUG: unable to handle page fault for address: ffffffffc0fd4b5d
Call Trace:
 string+0x48/0xe0
 vsnprintf+0x1f9/0x650
 sprintf+0x62/0x80
 name_show+0x1f/0x30
 dev_attr_show+0x19/0x60

The call trace repeats approximately every 10 minutes when system monitoring tools (e.g., sadc) attempt to read the orphaned hwmon sysfs attributes that reference freed module memory.

The sequence is:
1. Driver load, ice_hwmon_init() gets called from ice_init_feature()
2. Devlink reload down, flow does not call ice_remove()
3. Devlink reload up, ice_hwmon_init() gets called from ice_init_feature() resulting in a second instance
4. Driver unload, ice_hwmon_exit() called from ice_remove() leaving the first hwmon instance orphaned with dangling pointer

Fix this by moving ice_hwmon_exit() from ice_remove() to ice_deinit_features() to ensure proper cleanup symmetry with ice_hwmon_init().

Fixes 4da71a77fc3b ("ice: read internal temperature sensor")
---
 drivers/net/ethernet/intel/ice/ice_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -2
index 71b85bf7b033..c7991fb80a86 100644
@@ -4836,6 +4836,7 @@ static void ice_deinit_features(struct ice_pf *pf)
 		ice_dpll_deinit(pf);
 	if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV)
 		xa_destroy(&pf->eswitch.reprs);
+	ice_hwmon_exit(pf);
 }
 
 static void ice_init_wakeup(struct ice_pf *pf)
@@ -5439,8 +5440,6 @@ static void ice_remove(struct pci_dev *pdev)
 		ice_free_vfs(pf);
 	}
 
-	ice_hwmon_exit(pf);
-
 	if (!ice_is_safe_mode(pf))
 		ice_remove_arfs(pf);
 
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw

Dear Paul,

Thank you for your patch.

Am 29.12.25 um 13:52 schrieb Paul Greenwalt:

Quoted 26 lines

Commit 4da71a77fc3b ("ice: read internal temperature sensor") introduced internal temperature sensor reading via HWMON. ice_hwmon_init() was added to ice_init_feature() and ice_hwmon_exit() was added to ice_remove(). As a result if devlink reload is used to reinit the device and then the driver is removed, a call trace can occur.

BUG: unable to handle page fault for address: ffffffffc0fd4b5d
Call Trace:
  string+0x48/0xe0
  vsnprintf+0x1f9/0x650
  sprintf+0x62/0x80
  name_show+0x1f/0x30
  dev_attr_show+0x19/0x60

The call trace repeats approximately every 10 minutes when system monitoring tools (e.g., sadc) attempt to read the orphaned hwmon sysfs attributes that reference freed module memory.

The sequence is:
1. Driver load, ice_hwmon_init() gets called from ice_init_feature()
2. Devlink reload down, flow does not call ice_remove()
3. Devlink reload up, ice_hwmon_init() gets called from ice_init_feature() resulting in a second instance
4. Driver unload, ice_hwmon_exit() called from ice_remove() leaving the first hwmon instance orphaned with dangling pointer

Quoted 3 lines

Fix this by moving ice_hwmon_exit() from ice_remove() to ice_deinit_features() to ensure proper cleanup symmetry with ice_hwmon_init().

Great commit message. For the summary/title/subject I’d make it more specific. Maybe:

ice: Move ice_hwmon_exit() to ice_deinit_features() to avoid accessing freed memory

(Is that UAF, use after free?)

Quoted 20 lines
Fixes 4da71a77fc3b ("ice: read internal temperature sensor")
---
  drivers/net/ethernet/intel/ice/ice_main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
index 71b85bf7b033..c7991fb80a86 100644
@@ -4836,6 +4836,7 @@ static void ice_deinit_features(struct ice_pf *pf)
  		ice_dpll_deinit(pf);
  	if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV)
  		xa_destroy(&pf->eswitch.reprs);
+	ice_hwmon_exit(pf);
  }
 
  static void ice_init_wakeup(struct ice_pf *pf)

drivers/net/ethernet/intel/ice/ice_main.c static void ice_remove(struct pci_dev *pdev) · line 5445

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_main.c +0 -2
@@ -5439,8 +5440,6 @@ static void ice_remove(struct pci_dev *pdev)
  		ice_free_vfs(pf);
  	}
 
-	ice_hwmon_exit(pf);
-
  	if (!ice_is_safe_mode(pf))
  		ice_remove_arfs(pf);
 

Kind regards,

Paul

Tested-by on v1 1/1
#2 lore raw
In reply to Paul Greenwalt
Quoted 16 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Paul Greenwalt
Sent: 29 December 2025 14:23
To: [email protected]
Cc: Greenwalt, Paul <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-net v1] ice: fix devlink reload call trace

Commit 4da71a77fc3b ("ice: read internal temperature sensor") introduced internal temperature sensor reading via HWMON. ice_hwmon_init() was added to ice_init_feature() and ice_hwmon_exit() was added to ice_remove(). As a result if devlink reload is used to reinit the device and then the driver is removed, a call trace can occur.

BUG: unable to handle page fault for address: ffffffffc0fd4b5d Call Trace:
string+0x48/0xe0
vsnprintf+0x1f9/0x650
sprintf+0x62/0x80
name_show+0x1f/0x30
dev_attr_show+0x19/0x60
Quoted 4 lines

The call trace repeats approximately every 10 minutes when system monitoring tools (e.g., sadc) attempt to read the orphaned hwmon sysfs attributes that reference freed module memory.

The sequence is:
1. Driver load, ice_hwmon_init() gets called from ice_init_feature() 2. Devlink reload down, flow does not call ice_remove() 3. Devlink reload up, ice_hwmon_init() gets called from

ice_init_feature() resulting in a second instance 4. Driver unload, ice_hwmon_exit() called from ice_remove() leaving the first hwmon instance orphaned with dangling pointer

Quoted 11 lines

Fix this by moving ice_hwmon_exit() from ice_remove() to ice_deinit_features() to ensure proper cleanup symmetry with ice_hwmon_init().

Fixes 4da71a77fc3b ("ice: read internal temperature sensor")

---
drivers/net/ethernet/intel/ice/ice_main.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)