Skip to contentSkip to conversation

EDAC/synopsys: Fix cleanup on injection sysfs failure

PATCH In review Yuho Choi 3 participants 3 messages Jun 5 – Jun 10

Subsystems (2)
lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH v2 1/1 EDAC/synopsys: Fix cleanup on injection sysfs failure

edac_create_sysfs_attributes() creates inject_data_error before inject_data_poison. If the second file creation fails, the first file is left behind.

The same failure path runs after edac_mc_add_mc() has registered the memory controller with the EDAC core. Jumping directly to edac_mc_free() skips edac_mc_del_mc() and leaves the registered controller state unwound incorrectly.

Remove inject_data_error when inject_data_poison creation fails, and route the probe failure through edac_mc_del_mc() before freeing mci.

Fixes 1a81361f75d8 ("EDAC, synopsys: Add Error Injection support for ZynqMP DDR controller")

---
Changes in v2:
- Remove the CONFIG_EDAC_DEBUG-guarded del_mc label.
- Call edac_mc_del_mc() inline before jumping to free_edac_mc when edac_create_sysfs_attributes() fails.

 drivers/edac/synopsys_edac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/edac/synopsys_edac.c +4 -1
index 51143b3257de..9ca2a842612e 100644
@@ -1120,8 +1120,10 @@ static int edac_create_sysfs_attributes(struct mem_ctl_info *mci)
 	if (rc < 0)
 		return rc;
 	rc = device_create_file(&mci->dev, &dev_attr_inject_data_poison);
-	if (rc < 0)
+	if (rc < 0) {
+		device_remove_file(&mci->dev, &dev_attr_inject_data_error);
 		return rc;
+	}
 	return 0;
 }
 
@@ -1431,6 +1433,7 @@ static int mc_probe(struct platform_device *pdev)
 		if (rc) {
 			edac_printk(KERN_ERR, EDAC_MC,
 					"Failed to create sysfs entries\n");
+			edac_mc_del_mc(&pdev->dev);
 			goto free_edac_mc;
 		}
 	}
Signature · 1 line
2.43.0
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 40 lines · Yuho Choi

edac_create_sysfs_attributes() creates inject_data_error before inject_data_poison. If the second file creation fails, the first file is left behind.

The same failure path runs after edac_mc_add_mc() has registered the memory controller with the EDAC core. Jumping directly to edac_mc_free() skips edac_mc_del_mc() and leaves the registered controller state unwound incorrectly.

Remove inject_data_error when inject_data_poison creation fails, and route the probe failure through edac_mc_del_mc() before freeing mci.

Fixes 1a81361f75d8 ("EDAC, synopsys: Add Error Injection support for ZynqMP DDR controller")

---
Changes in v2:
- Remove the CONFIG_EDAC_DEBUG-guarded del_mc label.
- Call edac_mc_del_mc() inline before jumping to free_edac_mc when edac_create_sysfs_attributes() fails.

  drivers/edac/synopsys_edac.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/edac/synopsys_edac.c +3 -1
index 51143b3257de..9ca2a842612e 100644
@@ -1120,8 +1120,10 @@ static int edac_create_sysfs_attributes(struct mem_ctl_info *mci)
  	if (rc < 0)
  		return rc;
  	rc = device_create_file(&mci->dev, &dev_attr_inject_data_poison);
-	if (rc < 0)
+	if (rc < 0) {
+		device_remove_file(&mci->dev, &dev_attr_inject_data_error);
  		return rc;
+	}
  	return 0;
  }
 

drivers/edac/synopsys_edac.c static int mc_probe(struct platform_device *pdev) · line 1439

Quoted 7 lines
drivers/edac/synopsys_edac.c +1 -0
@@ -1431,6 +1433,7 @@ static int mc_probe(struct platform_device *pdev)
  		if (rc) {
  			edac_printk(KERN_ERR, EDAC_MC,
  					"Failed to create sysfs entries\n");
+			edac_mc_del_mc(&pdev->dev);
  			goto free_edac_mc;
  		}
  	}

Thanks,
Michal

maintainer
#2 lore raw
In reply to Yuho Choi
Quoted 14 lines · Yuho Choi

edac_create_sysfs_attributes() creates inject_data_error before inject_data_poison. If the second file creation fails, the first file is left behind.

The same failure path runs after edac_mc_add_mc() has registered the memory controller with the EDAC core. Jumping directly to edac_mc_free() skips edac_mc_del_mc() and leaves the registered controller state unwound incorrectly.

Remove inject_data_error when inject_data_poison creation fails, and route the probe failure through edac_mc_del_mc() before freeing mci.

Fixes 1a81361f75d8 ("EDAC, synopsys: Add Error Injection support for ZynqMP DDR controller")
Quoted 8 lines

---
Changes in v2:
- Remove the CONFIG_EDAC_DEBUG-guarded del_mc label.
- Call edac_mc_del_mc() inline before jumping to free_edac_mc when edac_create_sysfs_attributes() fails.

 drivers/edac/synopsys_edac.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

https://sashiko.dev/#/patchset/20260605125417.2348115-1-dbgh9129%40gmail.com

Signature · 4 lines
Regards/Gruss,
    Boris.

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