Skip to content

Commit

Permalink
libsel4allocman: add error check
Browse files Browse the repository at this point in the history
The signature allows returning an error, so this must be checked.

Signed-off-by: Axel Heider <axelheider@gmx.de>
  • Loading branch information
axel-h committed Apr 12, 2024
1 parent f09dd0c commit 2b60731
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion libsel4allocman/src/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ static int bootstrap_add_untypeds_from_simple(bootstrap_info_t *bs, simple_t *si
if (!bs->have_boot_cspace || (bs->uts && !bs->uts_in_current_cspace)) {
return 1;
}
for (int i = 0; i < simple_get_untyped_count(simple); i++) {

int cnt = simple_get_untyped_count(simple);
if (cnt < 0) {
ZF_LOGE("Could not get untyped count (%d)", cnt);
return 1;
}

for (int i = 0; i < cnt; i++) {
size_t size_bits;
uintptr_t paddr;
bool device;
Expand Down Expand Up @@ -1111,6 +1118,10 @@ int allocman_add_simple_untypeds_with_regions(allocman_t *alloc, simple_t *simpl
ZF_LOGF_IF(error, "bootstrap_prepare_handle_device_untyped_cap Failed");

int total_untyped = simple_get_untyped_count(simple);
if (total_untyped < 0) {
ZF_LOGW("Could not get untyped count (%d)", total_untyped);
return 0; /* don't report an error, just do nothing */
}

for(int i = 0; i < total_untyped; i++) {
size_t size_bits;
Expand Down
8 changes: 7 additions & 1 deletion libsel4simple/src/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@

bool simple_is_untyped_cap(simple_t *simple, seL4_CPtr pos)
{
for (int i = 0; i < simple_get_untyped_count(simple); i++) {
int cnt = simple_get_untyped_count(simple);
if (cnt < 0) {
ZF_LOGE("Could not get untyped count (%d)", cnt);
return false;
}

for (int i = 0; i < cnt; i++) {
seL4_CPtr ut_pos = simple_get_nth_untyped(simple, i, NULL, NULL, NULL);
if (ut_pos == pos) {
return true;
Expand Down

0 comments on commit 2b60731

Please sign in to comment.