diff options
author | mav <mav@FreeBSD.org> | 2009-03-29 07:10:52 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2009-03-29 07:10:52 +0000 |
commit | 43b6409ff483b0dd4b9a1a3d2918b750fbec1579 (patch) | |
tree | 13ee9ddc9d0bfa253ba9db083622c226e6de919a /sys/dev/sound | |
parent | dd8829d949c6d50631f4997ee594e975cb98f077 (diff) | |
download | FreeBSD-src-43b6409ff483b0dd4b9a1a3d2918b750fbec1579.zip FreeBSD-src-43b6409ff483b0dd4b9a1a3d2918b750fbec1579.tar.gz |
Fixup relative pointers after channel realloc. It fixes crash on systems
with several HDA codecs per controller.
While I am there, remove some unneeded dereferences.
Submitted by: Tor Egge <Tor.Egge@cvsup.no.freebsd.org>
Diffstat (limited to 'sys/dev/sound')
-rw-r--r-- | sys/dev/sound/pci/hda/hdac.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 57cadd6..c87360f 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -83,7 +83,7 @@ #include "mixer_if.h" -#define HDA_DRV_TEST_REV "20090316_0130" +#define HDA_DRV_TEST_REV "20090329_0131" SND_DECLARE_FILE("$FreeBSD$"); @@ -5280,7 +5280,7 @@ hdac_audio_bind_as(struct hdac_devinfo *devinfo) sizeof(struct hdac_chan) * cnt, M_HDAC, M_ZERO | M_NOWAIT); if (sc->chans == NULL) { - device_printf(devinfo->codec->sc->dev, + device_printf(sc->dev, "Channels memory allocation failed!\n"); return; } @@ -5290,17 +5290,20 @@ hdac_audio_bind_as(struct hdac_devinfo *devinfo) M_HDAC, M_ZERO | M_NOWAIT); if (sc->chans == NULL) { sc->num_chans = 0; - device_printf(devinfo->codec->sc->dev, + device_printf(sc->dev, "Channels memory allocation failed!\n"); return; } + /* Fixup relative pointers after realloc */ + for (j = 0; j < sc->num_chans; j++) + sc->chans[j].caps.fmtlist = sc->chans[j].fmtlist; } free = sc->num_chans; sc->num_chans += cnt; for (j = free; j < free + cnt; j++) { - devinfo->codec->sc->chans[j].devinfo = devinfo; - devinfo->codec->sc->chans[j].as = -1; + sc->chans[j].devinfo = devinfo; + sc->chans[j].as = -1; } /* Assign associations in order of their numbers, */ @@ -5309,10 +5312,10 @@ hdac_audio_bind_as(struct hdac_devinfo *devinfo) continue; as[j].chan = free; - devinfo->codec->sc->chans[free].as = j; - devinfo->codec->sc->chans[free].dir = + sc->chans[free].as = j; + sc->chans[free].dir = (as[j].dir == HDA_CTL_IN) ? PCMDIR_REC : PCMDIR_PLAY; - hdac_pcmchannel_setup(&devinfo->codec->sc->chans[free]); + hdac_pcmchannel_setup(&sc->chans[free]); free++; } } |