Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/hdaudio Pull up following revision(s) (requested ...



details:   https://anonhg.NetBSD.org/src/rev/cfe7b6928fb5
branches:  netbsd-9
changeset: 948682:cfe7b6928fb5
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Dec 28 20:21:54 2020 +0000

description:
Pull up following revision(s) (requested by jmcneill in ticket #1166):

        sys/dev/hdaudio/hdaudio.c: revision 1.13

If the Subordinate Node Count returns 0 nodes, complain and return instead
of trying to kmem_zalloc 0 bytes later on.

diffstat:

 sys/dev/hdaudio/hdaudio.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (51 lines):

diff -r cc938cc7b9ed -r cfe7b6928fb5 sys/dev/hdaudio/hdaudio.c
--- a/sys/dev/hdaudio/hdaudio.c Mon Dec 28 20:18:09 2020 +0000
+++ b/sys/dev/hdaudio/hdaudio.c Mon Dec 28 20:21:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.9.2.1 2020/12/28 20:18:09 martin Exp $ */
+/* $NetBSD: hdaudio.c,v 1.9.2.2 2020/12/28 20:21:54 martin Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <support%precedence.co.uk@localhost>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.9.2.1 2020/12/28 20:18:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.9.2.2 2020/12/28 20:21:54 martin Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -713,6 +713,7 @@
 static void
 hdaudio_codec_attach(struct hdaudio_codec *co)
 {
+       struct hdaudio_softc *sc = co->co_host;
        struct hdaudio_function_group *fg;
        uint32_t vid, snc, fgrp;
        int starting_node, num_nodes, nid;
@@ -729,7 +730,6 @@
                return;
 
 #ifdef HDAUDIO_DEBUG
-       struct hdaudio_softc *sc = co->co_host;
        uint32_t rid = hdaudio_command(co, 0, CORB_GET_PARAMETER,
            COP_REVISION_ID);
        hda_print(sc, "Codec%02X: %04X:%04X HDA %d.%d rev %d stepping %d\n",
@@ -740,6 +740,16 @@
        starting_node = (snc >> 16) & 0xff;
        num_nodes = snc & 0xff;
 
+       /*
+        * If the total number of nodes is 0, there's nothing we can do.
+        * This shouldn't happen, so complain about it.
+        */
+       if (num_nodes == 0) {
+               hda_error(sc, "Codec%02X: No subordinate nodes found (%08x)\n",
+                   co->co_addr, snc);
+               return;
+       }
+
        co->co_nfg = num_nodes;
        co->co_fg = kmem_zalloc(co->co_nfg * sizeof(*co->co_fg), KM_SLEEP);
 



Home | Main Index | Thread Index | Old Index