diff --git a/stand/efi/include/efichar.h b/stand/efi/include/efichar.h --- a/stand/efi/include/efichar.h +++ b/stand/efi/include/efichar.h @@ -37,4 +37,12 @@ int utf8_to_ucs2(const char *, efi_char **, size_t *); int ucs2len(const efi_char *); +#ifdef _KERNEL +#define EFICHAR_MALLOC(sz) malloc((sz), M_TEMP, M_WAITOK | M_ZERO) +#define EFICHAR_FREE(sz) free((sz), M_TEMP) +#else +#define EFICHAR_MALLOC(sz) malloc(sz) +#define EFICHAR_FREE(sz) free(sz) +#endif + #endif /* _BOOT_EFI_EFICHAR_H_ */ diff --git a/stand/efi/libefi/efichar.c b/stand/efi/libefi/efichar.c --- a/stand/efi/libefi/efichar.c +++ b/stand/efi/libefi/efichar.c @@ -25,14 +25,21 @@ */ #include +#ifndef _KERNEL #include +#endif #ifdef _STANDALONE #include #else +#ifdef _KERNEL +#include +#include +#else #include #include #include #include +#endif #include #include #endif @@ -87,7 +94,7 @@ if (*name != NULL) cp = *name; else - cp = *name = malloc(sz); + cp = *name = EFICHAR_MALLOC(sz); if (*name == NULL) return (ENOMEM); @@ -114,7 +121,7 @@ if (len >= sz) { /* Absent bugs, we'll never return EOVERFLOW */ if (freeit) { - free(*name); + EFICHAR_FREE(*name); *name = NULL; } return (EOVERFLOW); @@ -135,7 +142,7 @@ sz = strlen(name) * 2 + 2; if (*nmp == NULL) - *nmp = malloc(sz); + *nmp = EFICHAR_MALLOC(sz); if (*nmp == NULL) return (ENOMEM); nm = *nmp; @@ -183,7 +190,7 @@ } if (sz < 2) { if (freeit) { - free(nm); + EFICHAR_FREE(nm); *nmp = NULL; } return (EDOOFUS); @@ -194,7 +201,7 @@ return (0); ilseq: if (freeit) { - free(nm); + EFICHAR_FREE(nm); *nmp = NULL; } return (EILSEQ);