From 0ded247f442f08656c8738ac6dcb2ef4308d7261 Mon Sep 17 00:00:00 2001 From: Ari Kimari Date: Fri, 29 Aug 2025 16:13:36 +0300 Subject: [PATCH] fs/fat: Fix wrong alloc used in fat_zero_cluster() Fat_zero_cluster() use fs_heap_malloc() for buffer that is used to call fat_hwread(). Fat_hwread() must be called with IO buffer that have proper alingment because it might use DMA. Fix changes fs_heap_malloc() to fat_io_alloc() which uses correct fat_dma_alloc() if CONFIG_FAT_DMAMEMORY is defined. Signed-off-by: Ari Kimari --- fs/fat/fs_fat32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index 39eca06e04..22db4a9786 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -509,7 +509,7 @@ static int fat_zero_cluster(FAR struct fat_mountpt_s *fs, int cluster, off_t end_sec = sector + DIV_ROUND_UP(end, fs->fs_hwsectorsize); int ret; - buf = fs_heap_malloc(fs->fs_hwsectorsize); + buf = fat_io_alloc(fs->fs_hwsectorsize); if (!buf) { return -ENOMEM; @@ -548,7 +548,7 @@ static int fat_zero_cluster(FAR struct fat_mountpt_s *fs, int cluster, ret = OK; out: - fs_heap_free(buf); + fat_io_free(buf, fs->fs_hwsectorsize); return ret; }