From owner-svn-src-head@FreeBSD.ORG Sun Mar 29 07:10:52 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 772D6106566C; Sun, 29 Mar 2009 07:10:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B7468FC0C; Sun, 29 Mar 2009 07:10:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2T7AqJQ024726; Sun, 29 Mar 2009 07:10:52 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2T7AqVQ024725; Sun, 29 Mar 2009 07:10:52 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <200903290710.n2T7AqVQ024725@svn.freebsd.org> From: Alexander Motin Date: Sun, 29 Mar 2009 07:10:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190519 - head/sys/dev/sound/pci/hda X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Mar 2009 07:10:52 -0000 Author: mav Date: Sun Mar 29 07:10:52 2009 New Revision: 190519 URL: http://svn.freebsd.org/changeset/base/190519 Log: 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 Modified: head/sys/dev/sound/pci/hda/hdac.c Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Sun Mar 29 03:30:15 2009 (r190518) +++ head/sys/dev/sound/pci/hda/hdac.c Sun Mar 29 07:10:52 2009 (r190519) @@ -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 * 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 * 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 * 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++; } }