From a9d7a75eaeec00c6499b54d5ed4fc0e97728b973 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 4 Jun 2026 17:34:18 +1000 Subject: [PATCH] extmod/vfs: Skip littlefs detection if mp_vfs_blockdev_read_ext() fails. Otherwise 'buf' is read uninitialised. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton Signed-off-by: Angus Gratton --- extmod/vfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extmod/vfs.c b/extmod/vfs.c index d2a7af5de00d4..c8297be3c143a 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -173,7 +173,9 @@ static mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) { mp_vfs_blockdev_init(&blockdev, bdev_obj); uint8_t buf[44]; for (size_t block_num = 0; block_num <= 1; ++block_num) { - mp_vfs_blockdev_read_ext(&blockdev, block_num, 8, sizeof(buf), buf); + if (mp_vfs_blockdev_read_ext(&blockdev, block_num, 8, sizeof(buf), buf) != 0) { + continue; + } #if MICROPY_VFS_LFS1 if (memcmp(&buf[32], "littlefs", 8) == 0) { // LFS1