Skip to contentSkip to conversation

drivers: base: Remove statistics group if encryption group not created

PATCH In review Ewan D. Milne 2 participants 2 messages Jul 13

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

PATCH v2 1/1 drivers: base: Remove statistics group if encryption group not created

If transport_add_class_device() gets an error from sysfs_create_group() when creating the encryption group, it does not remove the statistics group in the error path. Adjust the error path to do this properly.

v2: Only remove statistics group if tcont->statistics is non-NULL

Fixes bd2bc528691e ("scsi: scsi_transport_fc: Introduce encryption group")
Assisted-by Claude:claude-opus-4-6
---
 drivers/base/transport_class.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/base/transport_class.c +4 -1
index 416e9f819df5..351c3d3ce6a0 100644
@@ -168,11 +168,14 @@ static int transport_add_class_device(struct attribute_container *cont,
 	if (tcont->encryption) {
 		error = sysfs_create_group(&classdev->kobj, tcont->encryption);
 		if (error)
-			goto err_del;
+			goto err_del_statistics;
 	}
 
 	return 0;
 
+err_del_statistics:
+	if (tcont->statistics)
+		sysfs_remove_group(&classdev->kobj, tcont->statistics);
 err_del:
 	attribute_container_class_device_del(classdev);
 err_remove:
Signature · 1 line
2.52.0