From 9a7634536d89db3472b5d5431115497ae2c7caee Mon Sep 17 00:00:00 2001 From: Michael Knudsen Date: Wed, 6 Dec 2006 17:45:58 +0000 Subject: malloc(..., M_NOWAIT) with no NULL check is bad. If allocation fails, complain, clean up, and bail out of attach. input and ok gwk --- sys/dev/acpi/acpi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/dev') 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 * Copyright (c) 2005 Jordan Hargrave @@ -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)) { -- cgit v1.2.3