Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx5: IRQ, consolidate irq and affinity mask allocation

Consolidate the mlx5_irq and mlx5_irq->mask allocation, to simplify
error flows and to match the dealloctation sequence @irq_release for
symmetry.

Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>

+6 -8
+6 -8
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
··· 259 259 int err; 260 260 261 261 irq = kzalloc(sizeof(*irq), GFP_KERNEL); 262 - if (!irq) 262 + if (!irq || !zalloc_cpumask_var(&irq->mask, GFP_KERNEL)) { 263 + kfree(irq); 263 264 return ERR_PTR(-ENOMEM); 265 + } 266 + 264 267 if (!i || !pci_msix_can_alloc_dyn(dev->pdev)) { 265 268 /* The vector at index 0 is always statically allocated. If 266 269 * dynamic irq is not supported all vectors are statically ··· 300 297 mlx5_core_err(dev, "Failed to request irq. err = %d\n", err); 301 298 goto err_req_irq; 302 299 } 303 - if (!zalloc_cpumask_var(&irq->mask, GFP_KERNEL)) { 304 - mlx5_core_warn(dev, "zalloc_cpumask_var failed\n"); 305 - err = -ENOMEM; 306 - goto err_cpumask; 307 - } 300 + 308 301 if (af_desc) { 309 302 cpumask_copy(irq->mask, &af_desc->mask); 310 303 irq_set_affinity_and_hint(irq->map.virq, irq->mask); ··· 318 319 err_xa: 319 320 if (af_desc) 320 321 irq_update_affinity_hint(irq->map.virq, NULL); 321 - free_cpumask_var(irq->mask); 322 - err_cpumask: 323 322 free_irq(irq->map.virq, &irq->nh); 324 323 err_req_irq: 325 324 #ifdef CONFIG_RFS_ACCEL ··· 330 333 if (i && pci_msix_can_alloc_dyn(dev->pdev)) 331 334 pci_msix_free_irq(dev->pdev, irq->map); 332 335 err_alloc_irq: 336 + free_cpumask_var(irq->mask); 333 337 kfree(irq); 334 338 return ERR_PTR(err); 335 339 }