File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -211,14 +211,22 @@ static void start_mp(safe_mode_t safe_mode) {
211211
212212static void stop_mp (void ) {
213213 #if MICROPY_VFS
214- mp_vfs_mount_t * vfs = MP_STATE_VM (vfs_mount_table );
215214
216215 // Unmount all heap allocated vfs mounts.
217- while (gc_ptr_on_heap (vfs )) {
216+ mp_vfs_mount_t * vfs = MP_STATE_VM (vfs_mount_table );
217+ do {
218+ if (gc_ptr_on_heap (vfs )) {
219+ // mp_vfs_umount will splice out an unmounted vfs from the vfs_mount_table linked list.
220+ mp_vfs_umount (vfs -> obj );
221+ // Start over at the beginning of the list since the first entry may have been removed.
222+ vfs = MP_STATE_VM (vfs_mount_table );
223+ continue ;
224+ }
218225 vfs = vfs -> next ;
219- }
220- MP_STATE_VM ( vfs_mount_table ) = vfs ;
226+ } while ( vfs != NULL );
227+
221228 // The last vfs is CIRCUITPY and the root directory.
229+ vfs = MP_STATE_VM (vfs_mount_table );
222230 while (vfs -> next != NULL ) {
223231 vfs = vfs -> next ;
224232 }
You can’t perform that action at this time.
0 commit comments