Skip to contentSkip to conversation

EDAC/ghes: reset DMI scan state after registration failure

PATCH In review [email protected] 2 participants 2 messages Sep 9 – Sep 11

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

PATCH 1/1 EDAC/ghes: reset DMI scan state after registration failure

From: TanZheng <[email protected]>

ghes_scan_system() sets system_scanned after the DMI walk. The unlock path always kfree()s ghes_hw.dimms but left system_scanned and num_dimms set, so a later ghes_edac_register() skipped the scan and indexed a NULL dimms array.

Clear the scan flag (and num_dimms) in that shared unlock path when a scan actually ran. The next register() will walk DMI again.

---
 drivers/edac/ghes_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/ghes_edac.c +4 -0
index d80c88818691..b0630f1a2815 100644
@@ -499,6 +499,10 @@ static int ghes_edac_register(struct device *dev)
 	/* Not needed anymore */
 	kfree(ghes_hw.dimms);
 	ghes_hw.dimms = NULL;
+	if (system_scanned) {
+		system_scanned = false;
+		ghes_hw.num_dimms = 0;
+	}
 
 	mutex_unlock(&ghes_reg_mutex);
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 21 lines · On Wed, Sep 09, 2026 at 03:19:34PM +0800, [email protected] wrote:

From: TanZheng <[email protected]>

ghes_scan_system() sets system_scanned after the DMI walk. The unlock path always kfree()s ghes_hw.dimms but left system_scanned and num_dimms set, so a later ghes_edac_register() skipped the scan and indexed a NULL dimms array.

Clear the scan flag (and num_dimms) in that shared unlock path when a scan actually ran. The next register() will walk DMI again.

---
 drivers/edac/ghes_edac.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/edac/ghes_edac.c +0 -0
index d80c88818691..b0630f1a2815 100644

drivers/edac/ghes_edac.c static int ghes_edac_register(struct device *dev) · line 508

Quoted 10 lines
drivers/edac/ghes_edac.c +4 -0
@@ -499,6 +499,10 @@ static int ghes_edac_register(struct device *dev)
 	/* Not needed anymore */
 	kfree(ghes_hw.dimms);
 	ghes_hw.dimms = NULL;
+	if (system_scanned) {
+		system_scanned = false;
+		ghes_hw.num_dimms = 0;
+	}
 
 	mutex_unlock(&ghes_reg_mutex);
 

That's not the right fix. On unlock, it returns an error which the caller should check and then unwind by calling ghes_edac_unregister() on the already successfully registered instances.

But I don't have the necessary hardware to test it on and if you don't have it either, don't bother fixing it. Might as well obsolete this driver too.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette