Bail if we have a zero-length memory resource.

This commit is contained in:
mlelstv 2018-05-08 03:27:17 +00:00
parent ccca93f2fc
commit b23590a505
1 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdhc_acpi.c,v 1.4 2017/02/17 10:51:48 nonaka Exp $ */
/* $NetBSD: sdhc_acpi.c,v 1.5 2018/05/08 03:27:17 mlelstv Exp $ */
/*
* Copyright (c) 2016 Kimihiro Nonaka <nonaka@NetBSD.org>
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.4 2017/02/17 10:51:48 nonaka Exp $");
__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.5 2018/05/08 03:27:17 mlelstv Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -168,6 +168,10 @@ sdhc_acpi_attach(device_t parent, device_t self, void *opaque)
aprint_error_dev(self, "incomplete resources\n");
goto cleanup;
}
if (mem->ar_length == 0) {
aprint_error_dev(self, "zero length memory resource\n");
goto cleanup;
}
sc->sc_memsize = mem->ar_length;
if (bus_space_map(sc->sc_memt, mem->ar_base, sc->sc_memsize, 0,