Skip to content
Permalink
Browse files

fs/nvs: fix the sector size check

The sector size is 0 will pass "fs->sector_size % info.size" then start
a loop in nvs_startup() and never return. So retrun an error if the
sector size is 0.

Signed-off-by: Harry Jiang <explora26@gmail.com>
  • Loading branch information...
explora26 authored and carlescufi committed Aug 4, 2019
1 parent f7fd1ff commit 273bb8e2f764bebb04f8047006e084e34f6b7f69
Showing with 1 addition and 1 deletion.
  1. +1 −1 subsys/fs/nvs/nvs.c
@@ -701,7 +701,7 @@ int nvs_init(struct nvs_fs *fs, const char *dev_name)
LOG_ERR("Unable to get page info");
return -EINVAL;
}
if (fs->sector_size % info.size) {
if (!fs->sector_size || fs->sector_size % info.size) {
LOG_ERR("Invalid sector size");
return -EINVAL;
}

0 comments on commit 273bb8e

Please sign in to comment.
You can’t perform that action at this time.