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/1ec830db93b8
branches: trunk
changeset: 1021711:1ec830db93b8
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 ba8e4d4683e6 -r 1ec830db93b8 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 @@
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 @@
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 @@
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 @@
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 @@
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