Only unregister the sensors if these were successfully installed;

sysmon_envsys_unregister() does not check for NULL pointers gracefully.
This commit is contained in:
jruoho 2010-04-03 17:54:24 +00:00
parent 0876f873dd
commit a1264b7faf

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/buf.h>
@ -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);
}