Module Name: src Committed By: dholland Date: Mon May 3 04:36:43 UTC 2010
Modified Files: src/sys/dev/pci: azalia_codec.c Log Message: Fix a crash during alc888 initialization caused by holding a pointer across realloc. Patch from Bj?rn Barkenfelt in PR kern/41957, rearranged somewhat by myself. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/dev/pci/azalia_codec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/azalia_codec.c diff -u src/sys/dev/pci/azalia_codec.c:1.77 src/sys/dev/pci/azalia_codec.c:1.78 --- src/sys/dev/pci/azalia_codec.c:1.77 Tue Apr 7 14:47:53 2009 +++ src/sys/dev/pci/azalia_codec.c Mon May 3 04:36:43 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: azalia_codec.c,v 1.77 2009/04/07 14:47:53 stacktic Exp $ */ +/* $NetBSD: azalia_codec.c,v 1.78 2010/05/03 04:36:43 dholland Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.77 2009/04/07 14:47:53 stacktic Exp $"); +__KERNEL_RCSID(0, "$NetBSD: azalia_codec.c,v 1.78 2010/05/03 04:36:43 dholland Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -3176,9 +3176,9 @@ static int alc888_mixer_init(codec_t *this) { - mixer_item_t *m, *mdac = NULL; + mixer_item_t *m = NULL; mixer_devinfo_t *d; - int err, i; + int err, i, mdac_index = -1; err = generic_mixer_init(this); if (err) @@ -3193,10 +3193,10 @@ /* We're looking for front l/r mixer, which we know is nid 0x0c */ for (i = 0; i < this->nmixers; i++) if (this->mixers[i].nid == 0x0c) { - mdac = &this->mixers[i]; + mdac_index = i; break; } - if (mdac) { + if (mdac_index >= 0) { /* * ALC888 doesn't have a master mixer, so create a fake * inputs.dac that mirrors outputs.master @@ -3207,7 +3207,7 @@ m = &this->mixers[this->nmixers]; d = &m->devinfo; - memcpy(m, mdac, sizeof(*m)); + memcpy(m, &this->mixers[mdac_index], sizeof(*m)); d->mixer_class = AZ_CLASS_INPUT; snprintf(d->label.name, sizeof(d->label.name), AudioNdac); this->nmixers++;