Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/i2c Avoid double free when attach fails.
details: https://anonhg.NetBSD.org/src/rev/12008dd6927c
branches: trunk
changeset: 379680:12008dd6927c
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Jun 14 09:56:04 2021 +0000
description:
Avoid double free when attach fails.
diffstat:
sys/dev/i2c/adm1026.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (55 lines):
diff -r 27c9a4f74682 -r 12008dd6927c sys/dev/i2c/adm1026.c
--- a/sys/dev/i2c/adm1026.c Mon Jun 14 08:55:49 2021 +0000
+++ b/sys/dev/i2c/adm1026.c Mon Jun 14 09:56:04 2021 +0000
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.11 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adm1026.c,v 1.12 2021/06/14 09:56:04 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -235,6 +235,7 @@ adm1026_attach(device_t parent, device_t
aprint_error_dev(self,
"unable to register with sysmon\n");
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
return;
}
@@ -268,8 +269,8 @@ adm1026_detach(device_t self, int flags)
pmf_device_deregister(self);
- sysmon_envsys_unregister(sc->sc_sme);
- sc->sc_sme = NULL;
+ if (sc->sc_sme != NULL)
+ sysmon_envsys_unregister(sc->sc_sme);
return 0;
}
@@ -320,6 +321,7 @@ adm1026_setup_fans(struct adm1026_softc
if (sysmon_envsys_sensor_attach(
sc->sc_sme, &sc->sc_sensor[ADM1026_FAN_NUM(i)])) {
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
aprint_error_dev(sc->sc_dev,
"unable to attach fan %d at sysmon\n", i);
return;
@@ -377,6 +379,7 @@ adm1026_setup_temps(struct adm1026_softc
if (sysmon_envsys_sensor_attach(
sc->sc_sme, &sc->sc_sensor[ADM1026_TEMP_NUM(i)])) {
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
aprint_error_dev(sc->sc_dev,
"unable to attach temp %d at sysmon\n", i);
return;
@@ -402,6 +405,7 @@ adm1026_setup_volts(struct adm1026_softc
if (sysmon_envsys_sensor_attach(
sc->sc_sme, &sc->sc_sensor[ADM1026_VOLT_NUM(i)])) {
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
aprint_error_dev(sc->sc_dev,
"unable to attach volts %d at sysmon\n", i);
return;
Home |
Main Index |
Thread Index |
Old Index