drivers/mtd:fix uninit data in mtd_config_fs

Signed-off-by: XinStellaris <tianxin7@xiaomi.com>
This commit is contained in:
XinStellaris 2023-04-12 22:34:21 +08:00 committed by Xiang Xiao
parent 1530e04f20
commit a4546f35d2
1 changed files with 8 additions and 8 deletions

View File

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