diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2025-12-26 15:36:38 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2025-12-26 15:36:38 +0000 |
| commit | 4eb560faa725771e536a850a9467fbb592ab3c1b (patch) | |
| tree | 860c6fd78394041b77484bf55ad6e5796433a4ce | |
| parent | 88f8e3c5ab97025587d7df761c8ae72e2db6c1d3 (diff) | |
acpi: Reject duplicate handlers for ioctl commands
Reviewed by: imp
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D54311
| -rw-r--r-- | sys/dev/acpica/acpi.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 0549c83ded79..e49d3b4d1637 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -4203,7 +4203,7 @@ static int acpi_ioctl_hooks_initted; int acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg) { - struct acpi_ioctl_hook *hp; + struct acpi_ioctl_hook *hp, *thp; if ((hp = malloc(sizeof(*hp), M_ACPIDEV, M_NOWAIT)) == NULL) return (ENOMEM); @@ -4216,6 +4216,14 @@ acpi_register_ioctl(u_long cmd, acpi_ioctl_fn fn, void *arg) TAILQ_INIT(&acpi_ioctl_hooks); acpi_ioctl_hooks_initted = 1; } + TAILQ_FOREACH(thp, &acpi_ioctl_hooks, link) { + if (thp->cmd == cmd) { + ACPI_UNLOCK(acpi); + free(hp, M_ACPIDEV); + return (EBUSY); + } + } + TAILQ_INSERT_TAIL(&acpi_ioctl_hooks, hp, link); ACPI_UNLOCK(acpi); |
