PATCH: adaptec aha152x driver causes seg fault at boot

David Schleef (ds@stm.lbl.gov)
Tue, 9 Jun 1998 19:58:56 -0700 (PDT)


I found two little buglets in the aha152x driver in the 2.0.34
source (they are also in the 2.1.104 source). I just recently
removed an Adaptec AVA 1505 SCSI controller from my machine, but
LILO was still configured as:

image=/boot/vmlinuz
label=linux
root=/dev/hda1
read-only
append="aha152x=0x140,10"

Thus, the driver looks for the controller, thinking it should be
there. This leads to the first bug: if the controller is not
there (at least on my machine), the probing stops after the
message:

aha152x: tring software interrupt,

and never times out of the probe. I assume that one who is more
skilled in the ways of this controller can guess better than I about
this. If you (or someone) can provide me a guess, I can provide
the test...

However, I installed another controller (IDE) that uses IRQ 10, i.e.,
the same one that the adaptec controller is configured to probe, and
I get a seg fault after:

aha152x0: IRQ 10 already in use.
aha152x: driver needs an IRQ
scsi : 1 host.

It appears aha152x_detect() is returning 1, when it should be returning
0, since the device a) doesn't exist and/or b) has a bad IRQ. In the
process of writing a patch, I also noticed that "shpnt" is accessed
after the memory is freed; this is fixed also.

Included is a patch against 2.0.34, although it also works with
2.1.104.

dave...

--- linux/drivers/scsi/aha152x.c Tue Jun 9 19:31:06 1998
+++ linux/drivers/scsi/aha152x.c.new Tue Jun 9 17:59:30 1998
@@ -772,6 +772,7 @@
int aha152x_detect(Scsi_Host_Template * tpnt)
{
int i, j, ok;
+ int failed_count=0;
#if defined(AUTOCONF)
aha152x_config conf;
#endif
@@ -1018,8 +1019,10 @@
printk("\naha152x%d: Unexpected error code %d on requesting IRQ %d.\n", i, ok, shpnt->irq);
printk("aha152x: driver needs an IRQ.\n");

+ aha152x_host[shpnt->irq-IRQ_MIN]=0;
scsi_unregister(shpnt);
- shpnt=aha152x_host[shpnt->irq-IRQ_MIN]=0;
+ shpnt=0;
+ failed_count++;
continue;
}

@@ -1043,8 +1046,10 @@

printk("aha152x: IRQ %d possibly wrong. Please verify.\n", shpnt->irq);

+ aha152x_host[shpnt->irq-IRQ_MIN]=0;
scsi_unregister(shpnt);
- shpnt=aha152x_host[shpnt->irq-IRQ_MIN]=0;
+ shpnt=0;
+ failed_count++;
continue;
}

@@ -1061,7 +1066,7 @@
}
}

- return (setup_count>0);
+ return ((setup_count-failed_count)>0);
}

/*

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu