Skip to contentSkip to conversation

2.4.28 - AIC driver causes kernel corruption (as a module)

PATCH In review Mark Bellon 2 participants 3 messages Jan 11, 2005 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.28 - AIC driver causes kernel corruption (as a module)

Didn't see a patch for this and the problem is in the 2.4.28 sources.

The scsi_register_module call from within ah[cd]_linux_init causes the detect routine to be called. The detect routine calls ah[cd]_linux_pci_init which does a pci_register_driver call. If no hardware is found in the detect routine, ah[cd]_linux_init will exit without calling pci_unregister_driver leaving the kernel with pointers to a driver that never really loaded.

mark

Index: drivers/scsi/aic7xxx/aic79xx_osm.c
===================================================================
RCS file: /cvsdev/mvl-kernel/linux/drivers/scsi/aic7xxx/aic79xx_osm.c,v retrieving revision 1.2.4.2.12.4

scsi/aic7xxx/aic79xx_osm.c +3 -2
diff -a -u -r1.2.4.2.12.4 aic79xx_osm.c
@@ -5079,6 +5079,8 @@
 	}
 }
 
+static void ahd_linux_exit(void);
+
 static int __init
 ahd_linux_init(void)
 {
@@ -5087,8 +5089,7 @@
 #else
 	scsi_register_module(MODULE_SCSI_HA, &aic79xx_driver_template);
 	if (aic79xx_driver_template.present == 0) {
-		scsi_unregister_module(MODULE_SCSI_HA,
-				       &aic79xx_driver_template);
+		ahd_linux_exit();
 		return (-ENODEV);
 	}
 

Index: drivers/scsi/aic7xxx/aic7xxx_osm.c
===================================================================
RCS file: /cvsdev/mvl-kernel/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c,v retrieving revision 1.2.4.2.12.3

scsi/aic7xxx/aic7xxx_osm.c +3 -2
diff -a -u -r1.2.4.2.12.3 aic7xxx_osm.c
@@ -5077,6 +5077,8 @@
 	}
 }
 
+static void ahc_linux_exit(void);
+
 static int __init
 ahc_linux_init(void)
 {
@@ -5085,8 +5087,7 @@
 #else
 	scsi_register_module(MODULE_SCSI_HA, &aic7xxx_driver_template);
 	if (aic7xxx_driver_template.present == 0) {
-		scsi_unregister_module(MODULE_SCSI_HA,
-				       &aic7xxx_driver_template);
+		ahc_linux_exit();
 		return (-ENODEV);
 	}
 
#1 lore raw

scsi/aic7xxx/aic79xx_osm.c line 5092

Quoted 3 lines · Mark Bellon
scsi/aic7xxx/aic79xx_osm.c +1 -2
-		scsi_unregister_module(MODULE_SCSI_HA,
-				       &aic79xx_driver_template);
+		ahd_linux_exit();

Well, this is pretty much identical to the 2.6 fix for the same problem except that you forgot to remove the __exit designation from ah [cd]_linux_exit(). This is required to prevent hanging pointer references.

James

#2 lore raw
Quoted 14 lines · James Bottomley

Review

Quoted 5 lines · Mark Bellon
(quoted diff) +1 -2
-		scsi_unregister_module(MODULE_SCSI_HA,
-				       &aic79xx_driver_template);
+		ahd_linux_exit();

Well, this is pretty much identical to the 2.6 fix for the same problem except that you forgot to remove the __exit designation from ah [cd]_linux_exit(). This is required to prevent hanging pointer references.

Quoted 5 lines

James

Ah! Very true, very true. Updated patch attached.

mark

Index: drivers/scsi/aic7xxx/aic79xx_osm.c
===================================================================
RCS file: /cvsdev/mvl-kernel/linux/drivers/scsi/aic7xxx/aic79xx_osm.c,v retrieving revision 1.2.4.2.12.4

scsi/aic7xxx/aic79xx_osm.c +4 -3
diff -a -u -r1.2.4.2.12.4 aic79xx_osm.c
@@ -5079,6 +5079,8 @@
 	}
 }
 
+static void ahd_linux_exit(void);
+
 static int __init
 ahd_linux_init(void)
 {
@@ -5087,8 +5089,7 @@
 #else
 	scsi_register_module(MODULE_SCSI_HA, &aic79xx_driver_template);
 	if (aic79xx_driver_template.present == 0) {
-		scsi_unregister_module(MODULE_SCSI_HA,
-				       &aic79xx_driver_template);
+		ahd_linux_exit();
 		return (-ENODEV);
 	}
 
@@ -5096,7 +5097,7 @@
 #endif
 }
 
-static void __exit
+static void
 ahd_linux_exit(void)
 {
 	struct ahd_softc *ahd;

Index: drivers/scsi/aic7xxx/aic7xxx_osm.c
===================================================================
RCS file: /cvsdev/mvl-kernel/linux/drivers/scsi/aic7xxx/aic7xxx_osm.c,v retrieving revision 1.2.4.2.12.3

scsi/aic7xxx/aic7xxx_osm.c +4 -3
diff -a -u -r1.2.4.2.12.3 aic7xxx_osm.c
@@ -5077,6 +5077,8 @@
 	}
 }
 
+static void ahc_linux_exit(void);
+
 static int __init
 ahc_linux_init(void)
 {
@@ -5085,8 +5087,7 @@
 #else
 	scsi_register_module(MODULE_SCSI_HA, &aic7xxx_driver_template);
 	if (aic7xxx_driver_template.present == 0) {
-		scsi_unregister_module(MODULE_SCSI_HA,
-				       &aic7xxx_driver_template);
+		ahc_linux_exit();
 		return (-ENODEV);
 	}
 
@@ -5094,7 +5095,7 @@
 #endif
 }
 
-static void __exit
+static void
 ahc_linux_exit(void)
 {
 	struct ahc_softc *ahc;