anjiahao1 opened a new pull request, #22525: URL: https://github.com/apache/nuttx/pull/22525
## Summary Allocate the NVS config state with kmm_zalloc(). nvs_startup() initializes most of struct nvs_fs, but not every field: step_addr and the config cache (when CONFIG_MTD_CONFIG_CACHE_SIZE > 0) are never written before use. The state is allocated with kmm_malloc(), so those fields start as heap garbage. Allocate it with kmm_zalloc() so any unset field reads as zero. ## Impact * Is new feature added? NO - allocation fix. * Impact on user: NO * Impact on build: NO * Impact on hardware: NO * Impact on documentation: NO * Impact on security: NO * Impact on compatibility: NO ## Testing Build host: Linux x86_64, gcc 13.3. ``` tools/configure.sh -a <apps> sim:nsh # enable CONFIG_MTD and CONFIG_MTD_CONFIG_NVS make -j$(nproc) ``` The build completes with drivers/mtd/mtd_config_nvs.c compiled in (CC: mtd/mtd_config_nvs.c, LD: nuttx). The same configuration builds before and after the change; the difference is only the zeroed allocation. ## PR verification * [x] This PR introduces only one functional change. * [x] I have updated all required description fields above. * [x] My PR adheres to Contributing Guidelines and Documentation. * [ ] My PR is still work in progress (not ready for review). * [x] My PR is ready for review and can be safely merged into a codebase. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
