static int irq_thread(void *data)
 {
        struct callback_head on_exit_work;
-       static const struct sched_param param = {
-               .sched_priority = MAX_USER_RT_PRIO/2,
-       };
        struct irqaction *action = data;
        struct irq_desc *desc = irq_to_desc(action->irq);
        irqreturn_t (*handler_fn)(struct irq_desc *desc,
        else
                handler_fn = irq_thread_fn;
 
-       sched_setscheduler(current, SCHED_FIFO, ¶m);
-
        init_task_work(&on_exit_work, irq_thread_dtor);
        task_work_add(current, &on_exit_work, false);
 
         */
        if (new->thread_fn && !nested) {
                struct task_struct *t;
+               static const struct sched_param param = {
+                       .sched_priority = MAX_USER_RT_PRIO/2,
+               };
 
                t = kthread_create(irq_thread, new, "irq/%d-%s", irq,
                                   new->name);
                        ret = PTR_ERR(t);
                        goto out_mput;
                }
+
+               sched_setscheduler(t, SCHED_FIFO, ¶m);
+
                /*
                 * We keep the reference to the task struct even if
                 * the thread dies to avoid that the interrupt code