summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2022-08-01 14:44:15 +0000
committermlelstv <mlelstv@NetBSD.org>2022-08-01 14:44:15 +0000
commit6e42e955e46f9f2d5ea30aa77f2f44e3779fb4fa (patch)
tree70623f8edfb0e61c7147b4f6c7037d373537b4ae
parentca17363bf3fdf13ae102a8b348d9199e30712ac9 (diff)
Prevent multiple unregistrations.
-rw-r--r--sys/dev/ic/nslm7x.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c
index 1748c7008af..892011456b5 100644
--- a/sys/dev/ic/nslm7x.c
+++ b/sys/dev/ic/nslm7x.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nslm7x.c,v 1.76 2022/08/01 14:43:15 mlelstv Exp $ */
+/* $NetBSD: nslm7x.c,v 1.77 2022/08/01 14:44:15 mlelstv Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.76 2022/08/01 14:43:15 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.77 2022/08/01 14:44:15 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2247,6 +2247,7 @@ lm_attach(struct lm_softc *lmsc)
if ((rv = sysmon_envsys_sensor_attach(lmsc->sc_sme,
&lmsc->sensors[i])) != 0) {
sysmon_envsys_destroy(lmsc->sc_sme);
+ lmsc->sc_sme = NULL;
aprint_error_dev(lmsc->sc_dev,
"sysmon_envsys_sensor_attach() returned %d\n", rv);
return;
@@ -2270,6 +2271,7 @@ lm_attach(struct lm_softc *lmsc)
aprint_error_dev(lmsc->sc_dev,
"unable to register with sysmon\n");
sysmon_envsys_destroy(lmsc->sc_sme);
+ lmsc->sc_sme = NULL;
}
if (!pmf_device_register(lmsc->sc_dev, NULL, NULL))
aprint_error_dev(lmsc->sc_dev,
@@ -2285,7 +2287,9 @@ lm_detach(struct lm_softc *lmsc)
{
callout_halt(&lmsc->sc_callout, NULL);
callout_destroy(&lmsc->sc_callout);
- sysmon_envsys_unregister(lmsc->sc_sme);
+
+ if (lmsc->sc_sme != NULL)
+ sysmon_envsys_unregister(lmsc->sc_sme);
pmf_device_deregister(lmsc->sc_dev);
}