summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMichael Knudsen <mk@cvs.openbsd.org>2006-12-06 17:45:58 +0000
committerMichael Knudsen <mk@cvs.openbsd.org>2006-12-06 17:45:58 +0000
commit9a7634536d89db3472b5d5431115497ae2c7caee (patch)
tree79e68e34dde9ab5d8370612d6d7f729645ef85b2 /sys/dev
parent1c84ffdcd43b0e5f1a7bca0df1ee59eb0bea7f91 (diff)
malloc(..., M_NOWAIT) with no NULL check is bad. If allocation fails,
complain, clean up, and bail out of attach. input and ok gwk
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpi.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index a3c4390e5fe..584cdd14b4e 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.66 2006/11/28 20:25:59 jordan Exp $ */
+/* $OpenBSD: acpi.c,v 1.67 2006/12/06 17:45:57 mk Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -715,6 +715,11 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sleepbtn = 0;
sc->sc_note = malloc(sizeof(struct klist), M_DEVBUF, M_NOWAIT);
+ if (sc->sc_note == NULL) {
+ printf(": can't allocate memory\n");
+ acpi_unmap(&handle);
+ return;
+ }
memset(sc->sc_note, 0, sizeof(struct klist));
if (acpi_loadtables(sc, rsdp)) {