]> git.dujemihanovic.xyz Git - linux.git/commitdiff
net/mlx5: Fix error handling in irq_pool_request_irq
authorShay Drory <shayd@nvidia.com>
Tue, 30 Jul 2024 06:16:31 +0000 (09:16 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Aug 2024 01:04:51 +0000 (18:04 -0700)
In case mlx5_irq_alloc fails, the previously allocated index remains
in the XArray, which could lead to inconsistencies.

Fix it by adding error handling that erases the allocated index
from the XArray if mlx5_irq_alloc returns an error.

Fixes: c36326d38d93 ("net/mlx5: Round-Robin EQs over IRQs")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Maher Sanalla <msanalla@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Link: https://patch.msgid.link/20240730061638.1831002-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c

index f7b01b3f0cba360449533c03c148e2bbc3d53e0d..1477db7f5307e095ca1025417598c444215893d1 100644 (file)
@@ -48,6 +48,7 @@ static struct mlx5_irq *
 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;
 
@@ -64,9 +65,12 @@ irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_de
                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.