fs: ext2: Fix buffer overun
Rearrange check to make sure we do not access inode_pool[MAX_INODES].
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
diff --git a/subsys/fs/ext2/ext2_impl.c b/subsys/fs/ext2/ext2_impl.c
index 3a5382a..8714956 100644
--- a/subsys/fs/ext2/ext2_impl.c
+++ b/subsys/fs/ext2/ext2_impl.c
@@ -1501,7 +1501,7 @@
/* find entry */
uint32_t offset = 0;
- while (fs->inode_pool[offset] != inode && offset < MAX_INODES) {
+ while (offset < MAX_INODES && fs->inode_pool[offset] != inode) {
offset++;
}