Bring code into line with comment and ensure
authorkrw <krw@openbsd.org>
Mon, 3 Apr 2000 00:04:01 +0000 (00:04 +0000)
committerkrw <krw@openbsd.org>
Mon, 3 Apr 2000 00:04:01 +0000 (00:04 +0000)
that carr_freelist always has a carrier on
it. This should fix a problem where carr_freelist
has become NULL and then AdvISR() attempts to
put a carrier back on the list without checking
if carr_freelist is non-NULL.

This and the previous two changes to adwlib.c
and the change committed to adw.c at the same
time were derived in whole or part from work
done by/with dante@ from NetBSD.

sys/dev/ic/adwlib.c

index 4db6ad7..73cbea3 100644 (file)
@@ -1882,7 +1882,7 @@ ADW_SCSI_REQ_Q    *scsiq;
        ADW_CCB         *ccb;
        long            req_size;
        u_int32_t       req_paddr;
-       ADW_CARRIER     *new_carrp/*, *ccb_carr;
+       ADW_CARRIER     *new_carrp, *new_freep/*, *ccb_carr;
        int             i*/;
 
 
@@ -1902,11 +1902,14 @@ ADW_SCSI_REQ_Q  *scsiq;
         * Allocate a carrier ensuring at least one carrier always
         * remains on the freelist and initialize fields.
         */
-       if ((new_carrp = sc->carr_freelist) == NULL) {
+       new_carrp = sc->carr_freelist;
+        new_freep = adw_carrier_phys_kv( sc, 
+                                        ASC_GET_CARRP( new_carrp->next_vpa) );
+
+       if (new_freep == NULL) {
                return ADW_BUSY;
        }
-       sc->carr_freelist = adw_carrier_phys_kv(sc,
-                       ASC_GET_CARRP(new_carrp->next_vpa));
+       sc->carr_freelist = new_freep;
        sc->carr_pending_cnt++;
 
        /*