diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2026-03-30 13:38:54 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2026-03-30 13:41:06 +0000 |
| commit | cc2715cf1f864345ab175db691d4e152d5fb84af (patch) | |
| tree | 9c7a5efddf025e2a0d232c6721e65e9f4d88cec2 | |
| parent | e220af9cee74082841db9e80cbb73f570f3a570f (diff) | |
acpi_apm: Narrow scope of ACPI_LOCK
This lock doesn't need to be held across seldrain/knlist_destroy. It
is also redundant (and a bug) to hold it across knlist_add and
knlist_remove since it is the mutex for the knlist.
PR: 293901
Reported by: Jiaming Zhang <r772577952@gmail.com>
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D55994
| -rw-r--r-- | sys/x86/acpica/acpi_apm.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/sys/x86/acpica/acpi_apm.c b/sys/x86/acpica/acpi_apm.c index 919f76949dd4..71e2573d5fde 100644 --- a/sys/x86/acpica/acpi_apm.c +++ b/sys/x86/acpica/acpi_apm.c @@ -243,9 +243,9 @@ apmdtor(void *data) /* Remove this clone's data from the list and free it. */ ACPI_LOCK(acpi); STAILQ_REMOVE(&acpi_sc->apm_cdevs, clone, apm_clone_data, entries); + ACPI_UNLOCK(acpi); seldrain(&clone->sel_read); knlist_destroy(&clone->sel_read.si_note); - ACPI_UNLOCK(acpi); free(clone, M_APMDEV); } @@ -408,11 +408,9 @@ apmkqfilter(struct cdev *dev, struct knote *kn) struct apm_clone_data *clone; devfs_get_cdevpriv((void **)&clone); - ACPI_LOCK(acpi); kn->kn_hook = clone; kn->kn_fop = &apm_readfiltops; knlist_add(&clone->sel_read.si_note, kn, 0); - ACPI_UNLOCK(acpi); return (0); } @@ -421,10 +419,8 @@ apmreadfiltdetach(struct knote *kn) { struct apm_clone_data *clone; - ACPI_LOCK(acpi); clone = kn->kn_hook; knlist_remove(&clone->sel_read.si_note, kn, 0); - ACPI_UNLOCK(acpi); } static int @@ -433,8 +429,8 @@ apmreadfilt(struct knote *kn, long hint) struct apm_clone_data *clone; int sleeping; - ACPI_LOCK(acpi); clone = kn->kn_hook; + ACPI_LOCK(acpi); sleeping = clone->acpi_sc->acpi_next_stype != POWER_STYPE_AWAKE; ACPI_UNLOCK(acpi); return (sleeping); |
