1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
From 82513815bde3005f20ab904d9d64673b53b6a7c4 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Fri, 15 Apr 2016 14:38:52 +0200
Subject: [PATCH gnumach 1/2] i386: Fix error handling
* i386/i386at/model_dep.c (i386at_init): Fix error handling.
Signed-off-by: Justus Winter <justus@gnupg.org>
---
i386/i386at/model_dep.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index 62763ae..679d524 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -301,7 +301,8 @@ i386at_init(void)
* is too far in physical memory. */
if (boot_info.flags & MULTIBOOT_CMDLINE) {
int len = strlen ((char*)phystokv(boot_info.cmdline)) + 1;
- assert(init_alloc_aligned(round_page(len), &addr));
+ if (! init_alloc_aligned(round_page(len), &addr))
+ panic("could not allocate memory for multiboot command line");
kernel_cmdline = (char*) phystokv(addr);
memcpy(kernel_cmdline, (void *)phystokv(boot_info.cmdline), len);
boot_info.cmdline = addr;
@@ -311,20 +312,26 @@ i386at_init(void)
struct multiboot_module *m;
int i;
- assert(init_alloc_aligned(round_page(boot_info.mods_count * sizeof(*m)), &addr));
+ if (! init_alloc_aligned(
+ round_page(boot_info.mods_count * sizeof(*m)), &addr))
+ panic("could not allocate memory for multiboot modules");
m = (void*) phystokv(addr);
memcpy(m, (void*) phystokv(boot_info.mods_addr), boot_info.mods_count * sizeof(*m));
boot_info.mods_addr = addr;
for (i = 0; i < boot_info.mods_count; i++) {
vm_size_t size = m[i].mod_end - m[i].mod_start;
- assert(init_alloc_aligned(round_page(size), &addr));
+ if (! init_alloc_aligned(round_page(size), &addr))
+ panic("could not allocate memory for multiboot "
+ "module %d", i);
memcpy((void*) phystokv(addr), (void*) phystokv(m[i].mod_start), size);
m[i].mod_start = addr;
m[i].mod_end = addr + size;
size = strlen((char*) phystokv(m[i].string)) + 1;
- assert(init_alloc_aligned(round_page(size), &addr));
+ if (! init_alloc_aligned(round_page(size), &addr))
+ panic("could not allocate memory for multiboot "
+ "module command line %d", i);
memcpy((void*) phystokv(addr), (void*) phystokv(m[i].string), size);
m[i].string = addr;
}
--
2.1.4
|