Skip to content

Commit 536552c

Browse files
lyakhlgirdwood
authored andcommitted
llext: fix virtual memory region looping
The check virtual_region == NULL after a SYS_MM_DRV_MEMORY_REGION_FOREACH(virtual_memory_regions, virtual_region) {} loop is wrong and useless - the only way virtual_region can be NULL is if virtual_memory_regions == NULL and in that case the SYS_MM_DRV_MEMORY_REGION_FOREACH() loop will cause an immediate exception. Fix this by checking virtual_memory_regions != NULL before the loop. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent a42ee0d commit 536552c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/library_manager/llext_manager.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,15 @@ static int llext_manager_load_module(struct lib_manager_module *mctx)
251251
const struct sys_mm_drv_region *virtual_memory_regions = sys_mm_drv_query_memory_regions();
252252
const struct sys_mm_drv_region *virtual_region;
253253

254+
if (!virtual_memory_regions)
255+
return -EFAULT;
256+
254257
SYS_MM_DRV_MEMORY_REGION_FOREACH(virtual_memory_regions, virtual_region) {
255258
if (virtual_region->attr == VIRTUAL_REGION_LLEXT_LIBRARIES_ATTR)
256259
break;
257260
}
258-
if (!virtual_region || !virtual_region->size)
261+
262+
if (!virtual_region->size)
259263
return -EFAULT;
260264

261265
/* Copy Code */

0 commit comments

Comments
 (0)