snd_hda: Only free streams DMA maps if the streams list has been created

If hdac_attach fails prior to allocating sc->streams, cleanup in the
hdac_attach_fail label will dereference a NULL pointer, panicking.
This commit is contained in:
jhibbits 2018-07-30 15:15:33 +00:00
parent 4f94fb5d47
commit 02c875cb8f

View File

@ -1312,8 +1312,9 @@ hdac_attach(device_t dev)
hdac_attach_fail:
hdac_irq_free(sc);
for (i = 0; i < sc->num_ss; i++)
hdac_dma_free(sc, &sc->streams[i].bdl);
if (sc->streams != NULL)
for (i = 0; i < sc->num_ss; i++)
hdac_dma_free(sc, &sc->streams[i].bdl);
free(sc->streams, M_HDAC);
hdac_dma_free(sc, &sc->rirb_dma);
hdac_dma_free(sc, &sc->corb_dma);