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. */