diff --git a/source/fs/mufs/block.c b/source/fs/mufs/block.c index ca6f90b..2bc2015 100644 --- a/source/fs/mufs/block.c +++ b/source/fs/mufs/block.c @@ -72,6 +72,8 @@ int mufs_alloc_block(struct mufs *fs, uint32_t *found) if ((index = mufs_next_free_block(fs)) == SIZE_MAX) return -1; + flash_erase(fs->dev, index, 1); + *found = index; return mufs_mark_block(fs, index, 1); @@ -87,7 +89,5 @@ int mufs_free_block(struct mufs *fs, uint32_t block) if (block < 1 + nbitmap_size) return -1; - flash_erase(fs->dev, block, 1); - return mufs_mark_block(fs, block, 0); }