diff --git a/usr.sbin/bhyve/pci_hda.c b/usr.sbin/bhyve/pci_hda.c index bb8fba1a54bb..9e9d7ab5a626 100644 --- a/usr.sbin/bhyve/pci_hda.c +++ b/usr.sbin/bhyve/pci_hda.c @@ -475,12 +475,14 @@ hda_send_command(struct hda_softc *sc, uint32_t verb) struct hda_codec_class *codec = NULL; uint8_t cad = (verb >> HDA_CMD_CAD_SHIFT) & 0x0f; - hci = sc->codecs[cad]; - if (!hci) + if (cad >= sc->codecs_no) return (-1); DPRINTF("cad: 0x%x verb: 0x%x", cad, verb); + hci = sc->codecs[cad]; + assert(hci); + codec = hci->codec; assert(codec);