--- x/fs/exfat/dir.c +++ y/fs/exfat/dir.c @@ -229,11 +229,10 @@ static int exfat_iterate(struct file *fi int err = 0, fake_offset = 0; exfat_init_namebuf(nb); - mutex_lock(&EXFAT_SB(sb)->s_lock); cpos = ctx->pos; if (!dir_emit_dots(file, ctx)) - goto unlock; + goto out_unlocked; if (ctx->pos == ITER_POS_FILLED_DOTS) { cpos = 0; @@ -245,7 +244,8 @@ static int exfat_iterate(struct file *fi /* name buffer should be allocated before use */ err = exfat_alloc_namebuf(nb); if (err) - goto unlock; + goto out_unlocked; + mutex_lock(&EXFAT_SB(sb)->s_lock); get_new: if (ei->flags == ALLOC_NO_FAT_CHAIN && cpos >= i_size_read(inode)) goto end_of_dir; @@ -294,7 +294,6 @@ end_of_dir: if (!cpos && fake_offset) cpos = ITER_POS_FILLED_DOTS; ctx->pos = cpos; -unlock: mutex_unlock(&EXFAT_SB(sb)->s_lock); out_unlocked: /*