diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 7446bf09a..6efbb5787 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -791,6 +791,7 @@ static int __exfat_get_dentry_set(struct exfat_entry_set_cache *es, es->modified = false; es->start_off = off; es->bh = es->__bh; + memset(es->__bh, 0, sizeof(es->__bh)); bh = sb_bread(sb, sec); if (!bh) @@ -801,6 +802,12 @@ static int __exfat_get_dentry_set(struct exfat_entry_set_cache *es, struct exfat_dentry *ep; ep = exfat_get_dentry_cached(es, ES_IDX_FILE); + + if (!ep) { + brelse(bh); + return -EIO; + } + if (ep->type != EXFAT_FILE) { brelse(bh); return -EIO;