fix: address Preloop review findings for RAM staging - #1
Conversation
Gate Zephyr RAM staging behind Kconfig, use mender_malloc, add unit-tested helpers, and fix the ESP-IDF partition-label cmake mismatch plus log truncation. Co-authored-by: Cursor <cursoragent@cursor.com>
| return MENDER_FAIL; | ||
| } | ||
|
|
||
| mender_image_ram_stage_reset(stage); |
There was a problem hiding this comment.
[LOW] [Quality]
Affected files:
src/core/image-ram-stage.c:31-46
mender_image_ram_stage_begin unconditionally calls mender_image_ram_stage_reset(stage), which mender_frees stage->buf. If a caller ever passes a non-zero-initialized struct (e.g. a stack mender_image_ram_stage_t stage; without = {0}), reset could free a garbage pointer. The only current caller is a zero-initialized static, and the unit tests use = {}, so this is latent rather than active.
Recommendation:
Document in the header that the struct must be zero-initialized before begin, or only free when buf != NULL after an internal init guard.
⏳ Still open as of commit 0da7502 — this issue has not been addressed yet.
🔍 Preloop Code ReviewLast Updated: 2026-08-04 📝 SummaryThis PR addresses prior review findings: it gates Zephyr ✅ What Looks Good
|
|
Superseded by recheck PR with the same commit for a clean Preloop trigger. |
Summary
zephyr-imageRAM staging behindCONFIG_MENDER_ZEPHYR_IMAGE_RAM_STAGE(+ optional max-bytes cap); usemender_malloc/mender_freevia shared helpers with unit tests; keep NULL-handle checks and direct-to-flash fallback.MENDER_STORAGE_PARTITION_LABELcmake/macro mismatch; grow ESP-IDF log formatting past a fixed 256-byte stack buffer.MENDER_MCU_PIN_BRANCH,DD_ROOT,MENDER_MCU_CONSUMERS); document RAM staging in README/CHANGELOG.Test plan
tests/unitImageRamStage*(5 tests) pass locallyAI disclosure
This PR was AI-assisted (Cursor).
Made with Cursor
Note
[Low Risk]
No security issues; the changes gate RAM staging behind a config, refactor staging into shared tested helpers, and fix an ESP-IDF macro/build mismatch. Only a minor, non-blocking quality suggestion applies.
Overview
This PR addresses prior review findings for RAM staging on Zephyr: adds config gating and a size cap, extracts staging into
mender_image_ram_stage_*helpers backed bymender_malloc/mender_freewith unit tests and direct-to-flash fallback, and fixes the ESP-IDFMENDER_STORAGE_PARTITION_LABELbuild/macro mismatch plus oversized log formatting.Written by Preloop PR Reviewer for commit 0da7502. Updates automatically on new commits.