Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Fix a crash during alc888 initialization caused ...



details:   https://anonhg.NetBSD.org/src/rev/b11ef03eff3e
branches:  trunk
changeset: 754524:b11ef03eff3e
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon May 03 04:36:43 2010 +0000

description:
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.

diffstat:

 sys/dev/pci/azalia_codec.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (52 lines):

diff -r e2a87a3f3de2 -r b11ef03eff3e sys/dev/pci/azalia_codec.c
--- a/sys/dev/pci/azalia_codec.c        Mon May 03 03:47:51 2010 +0000
+++ b/sys/dev/pci/azalia_codec.c        Mon May 03 04:36:43 2010 +0000
@@ -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++;



Home | Main Index | Thread Index | Old Index