Skip to contentSkip to conversation

fix module_init functions of transport classes

PATCH New Heiko Carstens 1 participant 1 message Jan 11, 2005

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

PATCH 1/1 fix module_init functions of transport classes

Hi James,

thanks for explaining the object lifetimes rules in the SCSI stack to me. Unfortunately I don't think I could exploit that to solve the zfcp problem.

While looking at the FC transport class code I think there is a minor bug if class_register fails in the module_init code. The class_unregister call of the succeeded class_register call seems to be missing. Patch below is untested.

Heiko

===== scsi_transport_fc.c 1.11 vs edited =====

scsi_transport_fc.c renamed from drivers/scsi/scsi_transport_fc.c +4 -1
@@ -222,7 +222,10 @@
 	int error = class_register(&fc_host_class);
 	if (error)
 		return error;
-	return class_register(&fc_transport_class);
+	error = class_register(&fc_transport_class);
+	if (error)
+		class_unregister(&fc_host_class);
+	return error;
 }
 
 static void __exit fc_transport_exit(void)

===== scsi_transport_spi.c 1.21 vs edited =====

scsi_transport_spi.c renamed from drivers/scsi/scsi_transport_spi.c +4 -1
@@ -134,7 +134,10 @@
 	int error = class_register(&spi_host_class);
 	if (error)
 		return error;
-	return class_register(&spi_transport_class);
+	error = class_register(&spi_transport_class);
+	if (error)
+		class_unregister(&spi_host_class);
+	return error;
 }
 
 static void __exit spi_transport_exit(void)

===== scsi_transport_iscsi.c 1.1 vs edited =====

scsi_transport_iscsi.c renamed from drivers/scsi/scsi_transport_iscsi.c +4 -1
@@ -338,7 +338,10 @@
 
 	if (err)
 		return err;
-	return class_register(&iscsi_host_class);
+	err = class_register(&iscsi_host_class);
+	if (err)
+		class_unregister(&iscsi_transport_class);
+	return err;
 }
 
 static void __exit iscsi_transport_exit(void)