summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2009-10-26 20:17:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2009-10-26 20:17:28 +0000
commitc16d88bf4bfc8e8526f12a85971a6f35865648c5 (patch)
tree195dce594f943b0bd5fcf3230f02adb820deba01 /sys/dev/acpi
parenta9810f2e4406559596eb8337a7a35f248cdbb080 (diff)
Do not do strncmp comparisons on dv_xname because longer device names which
look similar could arrive in the future. Instead, compare directly against dv_cfdata->cf_driver->cd_name Issue originally spotted by miod
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpi.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 38cd7e9849f..937223bb47f 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.142 2009/10/26 19:56:01 jordan Exp $ */
+/* $OpenBSD: acpi.c,v 1.143 2009/10/26 20:17:26 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -400,7 +400,7 @@ acpiide_notify(struct aml_node *node, int ntype, void *arg)
/* Walk device list looking for IDE device match */
TAILQ_FOREACH(dev, &alldevs, dv_list) {
- if (strncmp(dev->dv_xname, "pciide", 6))
+ if (strcmp(dev->dv_cfdata->cf_driver->cd_name, "pciide"))
continue;
wsc = (struct pciide_softc *)dev;
@@ -729,12 +729,11 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
SLIST_INIT(&sc->sc_ac);
SLIST_INIT(&sc->sc_bat);
TAILQ_FOREACH(dev, &alldevs, dv_list) {
- if (!strncmp(dev->dv_xname, "acpiac", strlen("acpiac"))) {
+ if (!strcmp(dev->dv_cfdata->cf_driver->cd_name, "acpiac")) {
ac = malloc(sizeof(*ac), M_DEVBUF, M_WAITOK | M_ZERO);
ac->aac_softc = (struct acpiac_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_ac, ac, aac_link);
- }
- if (!strncmp(dev->dv_xname, "acpibat", strlen("acpibat"))) {
+ } else if (!strcmp(dev->dv_cfdata->cf_driver->cd_name, "acpibat")) {
bat = malloc(sizeof(*bat), M_DEVBUF, M_WAITOK | M_ZERO);
bat->aba_softc = (struct acpibat_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_bat, bat, aba_link);