git: cf3e63b842f5 - main - asmc: clear the sensor counts in detach
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 15 Nov 2026 21:21:51 UTC
The branch main has been updated by seuros:
URL: https://cgit.FreeBSD.org/src/commit/?id=cf3e63b842f5e13dca93d8e218ef48892b358a71
commit cf3e63b842f5e13dca93d8e218ef48892b358a71
Author: Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-15 21:12:46 +0000
Commit: Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-15 21:12:46 +0000
asmc: clear the sensor counts in detach
The key arrays are freed but the counts were left set, leaving the
softc describing freed memory. Reachable via the attach error path,
which calls detach directly.
MFC after: 3 days
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D61483
---
sys/dev/asmc/asmc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index f7635b4d7550..231006f63bb3 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -352,16 +352,21 @@ asmc_detach(device_t dev)
/* Free temperature sensor key arrays */
for (int i = 0; i < sc->sc_temp_count; i++)
free(sc->sc_temp_sensors[i], M_DEVBUF);
+ sc->sc_temp_count = 0;
/* Free sensor key arrays */
for (int i = 0; i < sc->sc_voltage_count; i++)
free(sc->sc_voltage_sensors[i], M_DEVBUF);
+ sc->sc_voltage_count = 0;
for (int i = 0; i < sc->sc_current_count; i++)
free(sc->sc_current_sensors[i], M_DEVBUF);
+ sc->sc_current_count = 0;
for (int i = 0; i < sc->sc_power_count; i++)
free(sc->sc_power_sensors[i], M_DEVBUF);
+ sc->sc_power_count = 0;
for (int i = 0; i < sc->sc_light_count; i++)
free(sc->sc_light_sensors[i], M_DEVBUF);
+ sc->sc_light_count = 0;
if (sc->sc_sms_tq) {
taskqueue_drain(sc->sc_sms_tq, &sc->sc_sms_task);