static inline bool io_run_task_work(void)
 {
-       /*
-        * Not safe to run on exiting task, and the task_work handling will
-        * not add work to such a task.
-        */
-       if (unlikely(current->flags & PF_EXITING))
-               return false;
        if (current->task_works) {
                __set_current_state(TASK_RUNNING);
                task_work_run();
                ret |= io_cancel_defer_files(ctx, task, cancel_all);
                ret |= io_poll_remove_all(ctx, task, cancel_all);
                ret |= io_kill_timeouts(ctx, task, cancel_all);
-               ret |= io_run_task_work();
+               if (task)
+                       ret |= io_run_task_work();
                ret |= io_run_ctx_fallback(ctx);
                if (!ret)
                        break;