Skip to content

Commit 93e588b

Browse files
Shawnshhwenlingz
authored andcommitted
hv: fix e820.c violations
fix e820.c violations related misra c. Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com>
1 parent 60f78e1 commit 93e588b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

hypervisor/arch/x86/e820.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ uint64_t e820_alloc_low_memory(uint32_t size_arg)
121121
{
122122
uint32_t i;
123123
uint32_t size = size_arg;
124+
uint64_t ret = ACRN_INVALID_HPA;
124125
struct e820_entry *entry, *new_entry;
125126

126127
/* We want memory in page boundary and integral multiple of pages */
@@ -144,7 +145,8 @@ uint64_t e820_alloc_low_memory(uint32_t size_arg)
144145
if (length == size) {
145146
entry->type = E820_TYPE_RESERVED;
146147
e820_mem.total_mem_size -= size;
147-
return start;
148+
ret = start;
149+
break;
148150
}
149151

150152
/*
@@ -161,11 +163,14 @@ uint64_t e820_alloc_low_memory(uint32_t size_arg)
161163
e820_mem.total_mem_size -= new_entry->length;
162164
e820_entries_count++;
163165

164-
return new_entry->baseaddr;
166+
ret = new_entry->baseaddr;
167+
break;
165168
}
166169

167-
pr_fatal("Can't allocate memory under 1M from E820\n");
168-
return ACRN_INVALID_HPA;
170+
if (ret == ACRN_INVALID_HPA) {
171+
pr_fatal("Can't allocate memory under 1M from E820\n");
172+
}
173+
return ret;
169174
}
170175

171176
/* HV read multiboot header to get e820 entries info and calc total RAM info */

0 commit comments

Comments
 (0)