Module Name: src
Committed By: mlelstv
Date: Mon Aug 1 14:44:15 UTC 2022
Modified Files:
src/sys/dev/ic: nslm7x.c
Log Message:
Prevent multiple unregistrations.
To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/ic/nslm7x.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/nslm7x.c
diff -u src/sys/dev/ic/nslm7x.c:1.76 src/sys/dev/ic/nslm7x.c:1.77
--- src/sys/dev/ic/nslm7x.c:1.76 Mon Aug 1 14:43:15 2022
+++ src/sys/dev/ic/nslm7x.c Mon Aug 1 14:44:15 2022
@@ -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);
}