Page MenuHomeFreeBSD

D44541.diff
No OneTemporary

D44541.diff

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 <sys/types.h>
+#ifndef _KERNEL
#include <errno.h>
+#endif
#ifdef _STANDALONE
#include <stand.h>
#else
+#ifdef _KERNEL
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#else
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#endif
#include <sys/efi.h>
#include <machine/efi.h>
#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);

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 14, 5:22 PM (2 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25294767
Default Alt Text
D44541.diff (1 KB)

Event Timeline