This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new e5591ed9ca0 drivers/mtd: zero-initialize the NVS config state
e5591ed9ca0 is described below

commit e5591ed9ca060c70536fa7f492787dde675860ad
Author: anjiahao <[email protected]>
AuthorDate: Sun Nov 29 00:11:14 2026 +0800

    drivers/mtd: zero-initialize the NVS config state
    
    nvs_startup() initializes most of struct nvs_fs but not every field,
    and the structure is allocated with kmm_malloc(), so fields such as
    step_addr and the config cache start as heap garbage.  Allocate the
    state with kmm_zalloc() so an unset field reads as zero.
    
    Signed-off-by: anjiahao <[email protected]>
---
 drivers/mtd/mtd_config_nvs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtd_config_nvs.c b/drivers/mtd/mtd_config_nvs.c
index c18fbf8ab28..163d745bcef 100644
--- a/drivers/mtd/mtd_config_nvs.c
+++ b/drivers/mtd/mtd_config_nvs.c
@@ -2497,7 +2497,7 @@ int mtdconfig_register_by_path(FAR struct mtd_dev_s *mtd,
   FAR struct nvs_fs *fs;
   int rc;
 
-  fs = kmm_malloc(sizeof(struct nvs_fs));
+  fs = kmm_zalloc(sizeof(struct nvs_fs));
   if (fs == NULL)
     {
       return -ENOMEM;

Reply via email to