From 018696dd6699d8d24e6272fc9a3626c76be04f7a Mon Sep 17 00:00:00 2001 From: dyoung Date: Tue, 17 Mar 2009 19:38:34 +0000 Subject: [PATCH] Handle child-detachment by NULL'ing the child pointer so that auich_detach() does not subsequently dereference a dangling pointer. --- sys/dev/pci/auich.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/auich.c b/sys/dev/pci/auich.c index e2b95f75abe6..1b6a1134afa1 100644 --- a/sys/dev/pci/auich.c +++ b/sys/dev/pci/auich.c @@ -1,4 +1,4 @@ -/* $NetBSD: auich.c,v 1.128 2008/11/08 00:26:35 dyoung Exp $ */ +/* $NetBSD: auich.c,v 1.129 2009/03/17 19:38:34 dyoung Exp $ */ /*- * Copyright (c) 2000, 2004, 2005 The NetBSD Foundation, Inc. @@ -111,7 +111,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.128 2008/11/08 00:26:35 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: auich.c,v 1.129 2009/03/17 19:38:34 dyoung Exp $"); #include #include @@ -241,11 +241,13 @@ int auich_debug = 0xfffe; static int auich_match(device_t, cfdata_t, void *); static void auich_attach(device_t, device_t, void *); static int auich_detach(device_t, int); +static void auich_childdet(device_t, device_t); static int auich_activate(device_t, enum devact); static int auich_intr(void *); -CFATTACH_DECL_NEW(auich, sizeof(struct auich_softc), - auich_match, auich_attach, auich_detach, auich_activate); +CFATTACH_DECL2_NEW(auich, sizeof(struct auich_softc), + auich_match, auich_attach, auich_detach, auich_activate, NULL, + auich_childdet); static int auich_open(void *, int); static void auich_close(void *); @@ -690,6 +692,15 @@ auich_activate(device_t self, enum devact act) } return EOPNOTSUPP; } + +static void +auich_childdet(device_t self, device_t child) +{ + struct auich_softc *sc = device_private(self); + + KASSERT(sc->sc_audiodev == child); + sc->sc_audiodev = NULL; +} static int auich_detach(device_t self, int flags)