NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/58201: acpibat(4) is missing call to acpi_deregister_notify



>Number:         58201
>Category:       kern
>Synopsis:       acpibat(4) is missing call to acpi_deregister_notify
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 26 17:35:00 +0000 2024
>Originator:     Malte Dehling
>Release:        NetBSD 10.0, -current
>Organization:
>Environment:
    NetBSD 10.0 (GENERIC) #4: Wed Apr 24 12:21:26 PDT 2024
    mdehling@nb-base-dev:/scratch/obj/sys/arch/amd64/compile/GENERIC amd64

>Description:

Missing call to acpi_deregister_notify leads to use of resources that
have been freed in the (unlikely) case the call to
sysmon_envsys_register() fails.

>How-To-Repeat:

>Fix:

Prevent an issue in the unlikely case sysmon_envsys_register() fails.
---
 sys/dev/acpi/acpi_bat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/acpi/acpi_bat.c b/sys/dev/acpi/acpi_bat.c
index 617a2666c26..f8aa3925595 100644
--- a/sys/dev/acpi/acpi_bat.c
+++ b/sys/dev/acpi/acpi_bat.c
@@ -776,6 +776,8 @@ acpibat_init_envsys(device_t dv)
 fail:
 	aprint_error_dev(dv, "failed to initialize sysmon\n");

+	(void)acpi_deregister_notify(sc->sc_node);
+
 	sysmon_envsys_destroy(sc->sc_sme);
 	kmem_free(sc->sc_sensor, ACPIBAT_COUNT * sizeof(*sc->sc_sensor));

-- 
Malte Dehling



Home | Main Index | Thread Index | Old Index