From 17bfe5def6424c33dd1d3e6297a95ecf2c75ae4e Mon Sep 17 00:00:00 2001 From: Djordje Nedic Date: Wed, 11 Dec 2024 20:36:45 +0100 Subject: [PATCH] fs: littlefs: Fix cache and lookahead size checks in littlefs_fs for block devices This fixes an issue where wrong values were checked against block device defaults. Kconfig values are used when no filesystem config values are provided, and the buffers are sized according to the Kconfig values, but the checks were only performed against filesystem config variables. --- subsys/fs/littlefs_fs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index ff63770291be6fb..8840433b325a5f9 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -846,16 +846,16 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags) lcp->read_size = block_size; lcp->prog_size = block_size; - if (lcp->cache_size < new_cache_size) { - LOG_ERR("Configured cache size is too small: %d < %d", lcp->cache_size, + if (cache_size < new_cache_size) { + LOG_ERR("Configured cache size is too small: %d < %d", cache_size, new_cache_size); return -ENOMEM; } lcp->cache_size = new_cache_size; - if (lcp->lookahead_size < new_lookahead_size) { + if (lookahead_size < new_lookahead_size) { LOG_ERR("Configured lookahead size is too small: %d < %d", - lcp->lookahead_size, new_lookahead_size); + lookahead_size, new_lookahead_size); return -ENOMEM; } lcp->lookahead_size = new_lookahead_size;