static __cold void io_ring_ctx_free(struct io_ring_ctx *ctx)
 {
        io_sq_thread_finish(ctx);
-
-       if (ctx->mm_account) {
-               mmdrop(ctx->mm_account);
-               ctx->mm_account = NULL;
-       }
-
        io_rsrc_refs_drop(ctx);
        /* __io_rsrc_put_work() may need uring_lock to progress, wait w/o it */
        io_wait_rsrc_data(ctx->buf_data);
        WARN_ON_ONCE(!list_empty(&ctx->ltimeout_list));
        WARN_ON_ONCE(ctx->notif_slots || ctx->nr_notif_slots);
 
+       if (ctx->mm_account) {
+               mmdrop(ctx->mm_account);
+               ctx->mm_account = NULL;
+       }
        io_mem_free(ctx->rings);
        io_mem_free(ctx->sq_sqes);