zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.44k stars 6.4k forks source link

Memory mapping functions can return error without clean up #73121

Closed lyakh closed 1 week ago

lyakh commented 3 months ago

Describe the bug If asserts are disabled in a build, both generic and (probably derived from them) hardware-specific memory mapping functions like sys_mm_drv_simple_map_region(), sys_mm_drv_map_region(), sys_mm_drv_simple_map_array() can return in an error case without freeing resources, that they have been able to allocate.

Expected behavior In failure cases functions should clean up resources, that they've managed to allocate before the failure.

Impact In error cases can lead to resource exhaustion.

dcpleung commented 2 months ago

@lyakh Could you test the associated PR and see if that fixes the issue?