From a1264b7fafb6f159d0c0d0bd0e21ffbfff6bbff2 Mon Sep 17 00:00:00 2001 From: jruoho Date: Sat, 3 Apr 2010 17:54:24 +0000 Subject: [PATCH] Only unregister the sensors if these were successfully installed; sysmon_envsys_unregister() does not check for NULL pointers gracefully. --- sys/dev/pci/arcmsr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/arcmsr.c b/sys/dev/pci/arcmsr.c index 35ec0147568e..27683310627b 100644 --- a/sys/dev/pci/arcmsr.c +++ b/sys/dev/pci/arcmsr.c @@ -1,4 +1,4 @@ -/* $NetBSD: arcmsr.c,v 1.24 2010/04/03 14:19:17 pgoyette Exp $ */ +/* $NetBSD: arcmsr.c,v 1.25 2010/04/03 17:54:24 jruoho Exp $ */ /* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */ /* @@ -21,7 +21,7 @@ #include "bio.h" #include -__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.24 2010/04/03 14:19:17 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.25 2010/04/03 17:54:24 jruoho Exp $"); #include #include @@ -238,7 +238,9 @@ arc_detach(device_t self, int flags) if (arc_msg0(sc, ARC_REG_INB_MSG0_FLUSH_CACHE) != 0) aprint_error_dev(self, "timeout waiting to flush cache\n"); - sysmon_envsys_unregister(sc->sc_sme); + if (sc->sc_sme != NULL) + sysmon_envsys_unregister(sc->sc_sme); + return 0; } @@ -1805,8 +1807,12 @@ arc_create_sensors(void *arg) kthread_exit(0); bad: - kmem_free(sc->sc_sensors, slen); sysmon_envsys_destroy(sc->sc_sme); + kmem_free(sc->sc_sensors, slen); + + sc->sc_sme = NULL; + sc->sc_sensors = NULL; + kthread_exit(0); }