return 0;
 }
 
+/* Returns a locked folio on success.  */
 static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index, bool prepare)
 {
        struct folio *folio;
        fput(file);
 }
 
+/* Returns a locked folio on success.  */
 static struct folio *
 __kvm_gmem_get_pfn(struct file *file, struct kvm_memory_slot *slot,
                   gfn_t gfn, kvm_pfn_t *pfn, int *max_order, bool prepare)
        if (max_order)
                *max_order = 0;
 
-       folio_unlock(folio);
        return folio;
 }
 
        if (IS_ERR(folio))
                return PTR_ERR(folio);
 
+       folio_unlock(folio);
        return 0;
 }
 EXPORT_SYMBOL_GPL(kvm_gmem_get_pfn);
                        break;
                }
 
+               folio_unlock(folio);
                if (!IS_ALIGNED(gfn, (1 << max_order)) ||
                    (npages - i) < (1 << max_order))
                        max_order = 0;