diff --git a/subsys/fs/ext2/ext2_diskops.c b/subsys/fs/ext2/ext2_diskops.c index 7e6016a8bab..e6bdcf3ef6e 100644 --- a/subsys/fs/ext2/ext2_diskops.c +++ b/subsys/fs/ext2/ext2_diskops.c @@ -669,6 +669,10 @@ int64_t ext2_inode_remove_blocks(struct ext2_inode *inode, uint32_t first) max_lvl = get_level_offsets(inode->i_fs, first, offsets); + if (max_lvl < 0) { + return max_lvl; + } + if (all_zero(&offsets[1], max_lvl)) { /* The first block to remove is either: * - one of the first 12 blocks in the indode