diff options
author | 2006-12-06 17:45:57 +0000 | |
---|---|---|
committer | 2006-12-06 17:45:57 +0000 | |
commit | fda175c106770e0ae57445b8bc3305f59e0561ff (patch) | |
tree | fbea1919299b9ac68989ee15340b2f90ca881800 | |
parent | When compiled with UDCF_DEBUG, only output the bits received when (diff) | |
download | wireguard-openbsd-fda175c106770e0ae57445b8bc3305f59e0561ff.tar.xz wireguard-openbsd-fda175c106770e0ae57445b8bc3305f59e0561ff.zip |
malloc(..., M_NOWAIT) with no NULL check is bad. If allocation fails,
complain, clean up, and bail out of attach.
input and ok gwk
-rw-r--r-- | sys/dev/acpi/acpi.c | 7 |
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)) { |