Skip to content

Commit

Permalink
libsel4utils: fix null pointer reference
Browse files Browse the repository at this point in the history
add sanity check after alloc irq_server_t

Signed-off-by: chao an <anchao@xiaomi.com>
  • Loading branch information
anchao committed Sep 11, 2023
1 parent 1f03365 commit d9d6639
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libsel4utils/src/irq_server/irq_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,14 @@ irq_server_t *irq_server_new(vspace_t *vspace, vka_t *vka, seL4_Word priority,
irq_server_t *new = NULL;

error = ps_calloc(malloc_ops, 1, sizeof(irq_server_t), (void **) &new);
if (error) {
ZF_LOGE("Failed to allocate %zu bytes for irq_server", sizeof(irq_server_t));
return NULL;
}

if (config_set(CONFIG_KERNEL_MCS) && vka_alloc_reply(vka, &(new->reply)) != 0) {
ZF_LOGE("Failed to allocate reply object");
ps_free(malloc_ops, sizeof(irq_server_t), new);
return NULL;
}

Expand All @@ -349,6 +354,7 @@ irq_server_t *irq_server_new(vspace_t *vspace, vka_t *vka, seL4_Word priority,
error = sel4platsupport_new_irq_ops(&(new->irq_ops), vka, simple, irq_config, malloc_ops);
if (error) {
ZF_LOGE("Failed to initialise supporting backend for IRQ server");
ps_free(malloc_ops, sizeof(irq_server_t), new);
return NULL;
}

Expand Down

0 comments on commit d9d6639

Please sign in to comment.