Skip to content

Commit 76104a1

Browse files
committed
fix(core/remio): use of zero-sized array
The specific error is triggered in the macro expansion for OBJPOOL_ALLOC when the value CONFIG_REMIO_DEV_NUM assumes the value of 0. To solve this problem, we allocate only one slot if the user does not configure any Remote I/O device. Note: While we could use the #if macro to define the object pool only when a Remote I/O is configured, this approach would clutter the code with constant checks for device configuration whenever accessing certain variables. Signed-off-by: João Peixoto <[email protected]>
1 parent 3844229 commit 76104a1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/core/remio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ static void remio_cpu_handler(uint32_t event, uint64_t data);
138138
CPU_MSG_HANDLER(remio_cpu_handler, REMIO_CPUMSG_ID)
139139

140140
/** Object pool to allocate Remote I/O devices */
141-
OBJPOOL_ALLOC(remio_device_pool, struct remio_device, CONFIG_REMIO_DEV_NUM);
141+
OBJPOOL_ALLOC(remio_device_pool, struct remio_device,
142+
CONFIG_REMIO_DEV_NUM ? CONFIG_REMIO_DEV_NUM : 1);
142143

143144
/** Object pool to allocate pending Remote I/O requests events */
144145
OBJPOOL_ALLOC(remio_request_event_pool, struct remio_request_event, REMIO_VCPU_NUM);

src/core/vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <shmem.h>
1212
#include <objpool.h>
1313

14-
OBJPOOL_ALLOC(emul_cache, struct emul_mem, CONFIG_REMIO_DEV_NUM);
14+
OBJPOOL_ALLOC(emul_cache, struct emul_mem, CONFIG_REMIO_DEV_NUM ? CONFIG_REMIO_DEV_NUM : 1);
1515

1616
static void vm_master_init(struct vm* vm, const struct vm_config* vm_config, vmid_t vm_id)
1717
{

0 commit comments

Comments
 (0)