Author: will
Date: Fri Jan 23 23:53:56 2015
New Revision: 277622
URL: https://svnweb.freebsd.org/changeset/base/277622

Log:
  Fix panic in firewire and creation of invalid config ROM.
  (This change was supposed to be included in r277508.)
  
  sys/boot/i386/libfirewire/firewire.c:
        Fix configuration ROM generation count wrapping logic
        so that the generation count is never outside of
        allowed limits (0x2 -> 0xF).
  
  Submitted by: gibbs
  MFC after:    1 week
  MFC with:     277508
  Sponsored by: Spectra Logic
  MFSpectraBSD: 1110685 on 2015/01/05

Modified:
  head/sys/boot/i386/libfirewire/firewire.c

Modified: head/sys/boot/i386/libfirewire/firewire.c
==============================================================================
--- head/sys/boot/i386/libfirewire/firewire.c   Fri Jan 23 23:52:33 2015        
(r277621)
+++ head/sys/boot/i386/libfirewire/firewire.c   Fri Jan 23 23:53:56 2015        
(r277622)
@@ -233,7 +233,8 @@ fw_init_crom(struct fwohci_softc *sc)
        src->businfo.cyc_clk_acc = 100;
        src->businfo.max_rec = sc->maxrec;
        src->businfo.max_rom = MAXROM_4;
-       src->businfo.generation = 1;
+#define FW_GENERATION_CHANGEABLE 2
+       src->businfo.generation = FW_GENERATION_CHANGEABLE;
        src->businfo.link_spd = sc->speed;
 
        src->businfo.eui64.hi = sc->eui.hi;
@@ -313,11 +314,14 @@ fw_crom(struct fwohci_softc *sc)
        src = &sc->crom_src_buf->src;
        crom_load(src, (uint32_t *)newrom, CROMSIZE);
        if (bcmp(newrom, sc->config_rom, CROMSIZE) != 0) {
-               /* bump generation and reload */
-               src->businfo.generation ++;
-               /* generation must be between 0x2 and 0xF */
+               /* Bump generation and reload. */
+               src->businfo.generation++;
+
+               /* Handle generation count wraps. */
                if (src->businfo.generation < 2)
-                       src->businfo.generation ++;
+                       src->businfo.generation = 2;
+
+               /* Recalculate CRC to account for generation change. */
                crom_load(src, (uint32_t *)newrom, CROMSIZE);
                bcopy(newrom, (void *)sc->config_rom, CROMSIZE);
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to