Re: Bug#237477: kernel-image-2.6.3-1-686: loading the aic7xxxmodule and then another module crashes the kernel

From: Andrew Morton
Date: Sat Apr 03 2004 - 04:52:40 EST


Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> This is because aic7xxx does not unregister itself properly if
> no devices are found. This patch fixes the problem.

It doesn't seem right in ahc_linux_detect(). If CONFIG_EISA && !CONFIG_PCI
we end up calling ahc_linux_pci_exit() even though we never called
ahc_linux_pci_init().

And it will break compilation in ahc_linux_eisa_init() for 2.4 kernel.

Incremental patch:



---

25-akpm/drivers/scsi/aic7xxx/aic7770_osm.c | 8 ++++++--
25-akpm/drivers/scsi/aic7xxx/aic7xxx_osm.c | 12 ++++++------
2 files changed, 12 insertions(+), 8 deletions(-)

diff -puN drivers/scsi/aic7xxx/aic7xxx_osm.c~aic7xxx-unload-fix-fix drivers/scsi/aic7xxx/aic7xxx_osm.c
--- 25/drivers/scsi/aic7xxx/aic7xxx_osm.c~aic7xxx-unload-fix-fix 2004-04-03 01:45:02.657931472 -0800
+++ 25-akpm/drivers/scsi/aic7xxx/aic7xxx_osm.c 2004-04-03 01:45:02.666930104 -0800
@@ -899,8 +899,12 @@ ahc_linux_detect(Scsi_Host_Template *tem

#ifdef CONFIG_EISA
found = ahc_linux_eisa_init();
- if (found)
- goto out_pci;
+ if (found) {
+#ifdef CONFIG_PCI
+ ahc_linux_pci_exit();
+#endif
+ goto out;
+ }
#endif

/*
@@ -919,10 +923,6 @@ ahc_linux_detect(Scsi_Host_Template *tem

out:
return (found);
-
-out_pci:
- ahc_linux_pci_exit();
- goto out;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
diff -puN drivers/scsi/aic7xxx/aic7770_osm.c~aic7xxx-unload-fix-fix drivers/scsi/aic7xxx/aic7770_osm.c
--- 25/drivers/scsi/aic7xxx/aic7770_osm.c~aic7xxx-unload-fix-fix 2004-04-03 01:45:22.697884936 -0800
+++ 25-akpm/drivers/scsi/aic7xxx/aic7770_osm.c 2004-04-03 01:46:17.109613096 -0800
@@ -115,9 +115,10 @@ ahc_linux_eisa_init(void)
u_int slot;
u_int eisaBase;
u_int i;
+ int ret = -ENODEV;

if (aic7xxx_probe_eisa_vl == 0)
- return;
+ return ret;

eisaBase = 0x1000 + AHC_EISA_SLOT_OFFSET;
for (slot = 1; slot < NUMSLOTS; eisaBase+=0x1000, slot++) {
@@ -146,9 +147,12 @@ ahc_linux_eisa_init(void)
continue; /* no EISA card in slot */

entry = aic7770_find_device(eisa_id);
- if (entry != NULL)
+ if (entry != NULL) {
aic7770_linux_config(entry, NULL, eisaBase);
+ ret = 0;
+ }
}
+ return ret;
#endif
}


_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/