irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc)
 {
        struct irq_affinity_desc auto_desc = {};
+       struct mlx5_irq *irq;
        u32 irq_index;
        int err;
 
                else
                        cpu_get(pool, cpumask_first(&af_desc->mask));
        }
-       return mlx5_irq_alloc(pool, irq_index,
-                             cpumask_empty(&auto_desc.mask) ? af_desc : &auto_desc,
-                             NULL);
+       irq = mlx5_irq_alloc(pool, irq_index,
+                            cpumask_empty(&auto_desc.mask) ? af_desc : &auto_desc,
+                            NULL);
+       if (IS_ERR(irq))
+               xa_erase(&pool->irqs, irq_index);
+       return irq;
 }
 
 /* Looking for the IRQ with the smallest refcount that fits req_mask.