From a4546f35d239593080ec66c3651556b97e08af7c Mon Sep 17 00:00:00 2001 From: XinStellaris Date: Wed, 12 Apr 2023 22:34:21 +0800 Subject: [PATCH] drivers/mtd:fix uninit data in mtd_config_fs Signed-off-by: XinStellaris --- drivers/mtd/mtd_config_fs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/mtd_config_fs.c b/drivers/mtd/mtd_config_fs.c index e20b7246b6..5e47147034 100644 --- a/drivers/mtd/mtd_config_fs.c +++ b/drivers/mtd/mtd_config_fs.c @@ -991,14 +991,6 @@ static int nvs_startup(FAR struct nvs_fs *fs) fs->ate_wra = 0; fs->data_wra = 0; - /* Check the number of blocks, it should be at least 2. */ - - if (fs->geo.neraseblocks < 2) - { - ferr("Configuration error - block count\n"); - return -EINVAL; - } - /* Get the device geometry. (Casting to uintptr_t first eliminates * complaints on some architectures where the sizeof long is different * from the size of a pointer). @@ -1020,6 +1012,14 @@ static int nvs_startup(FAR struct nvs_fs *fs) return rc; } + /* Check the number of blocks, it should be at least 2. */ + + if (fs->geo.neraseblocks < 2) + { + ferr("Configuration error - block count\n"); + return -EINVAL; + } + /* Step through the blocks to find a open block following * a closed block, this is where NVS can write. */