1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 23:08:14 +00:00

core/modtrezorio: raise exception when directory listing fails on disk error or other error

This commit is contained in:
Ondrej Mikle 2019-09-02 17:33:41 +02:00 committed by Pavol Rusnak
parent 24359ea074
commit 59ee3750d1
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -272,7 +272,11 @@ STATIC mp_obj_t mod_trezorio_FatFSDir_iternext(mp_obj_t self) {
mp_obj_FatFSDir_t *o = MP_OBJ_TO_PTR(self);
FILINFO info;
FRESULT res = f_readdir(&(o->dp), &info);
if (res != FR_OK || info.fname[0] == 0) { // stop on error or end of dir
if (res != FR_OK) {
f_closedir(&(o->dp));
mp_raise_OSError(fresult_to_errno_table[res]);
}
if (info.fname[0] == 0) { // stop on end of dir
f_closedir(&(o->dp));
return MP_OBJ_STOP_ITERATION;
}