mlx4: FIX error flow when initializing EQ table
Subsystems (2)
PATCH 1/1 mlx4: FIX error flow when initializing EQ table
If mlx4_create_eq() would fail for one of EQ's assigned for completion handling, the code would try to free the same EQ we failed to create.
The crash was found by Christoph Lameter
--- drivers/net/mlx4/eq.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/mlx4/eq.c +3 -1
@@ -623,8 +623,10 @@ int mlx4_init_eq_table(struct mlx4_dev *dev) err =mlx4_create_eq (dev, dev->caps.num_cqs +MLX4_NUM_SPARE_EQE , (dev->flags &MLX4_FLAG_MSI_X ) ? i :0 , &priv->eq_table.eq[i]); -if (err) +if (err) { + --i; goto err_out_unmap; + } } err = mlx4_create_eq(dev, MLX4_NUM_ASYNC_EQE + MLX4_NUM_SPARE_EQE,
Signature · 1 line
1.6.1.3
From: Yevgeny Petrilin <[email protected]>
Date: Sun, 07 Jun 2009 18:16:09 +0300
Quoted 6 lines
If
mlx4_create_eq()would fail for one of EQ's assigned for completion handling, the code would try to free the same EQ we failed to create.
The crash was found by Christoph LameterSigned-off-by Yevgeny Petrilin <[email protected]>
Applied, thanks.
Quoted 5 lines
If
mlx4_create_eq()would fail for one of EQ's assigned for completion handling, the code would try to free the same EQ we failed to create.
The crash was found by Christoph Lameter
Thanks, good catch. However looking at the code it seems that a simpler way to fix this would be as below. Can you confirm that this works too?
--- drivers/net/mlx4/eq.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/mlx4/eq.c +3 -3
@@ -677,12 +677,12 @@ err_out_async:mlx4_free_eq (dev, &priv->eq_table.eq[dev->caps.num_comp_vectors]); err_out_comp: - i = dev->caps.num_comp_vectors -1 ; + i = dev->caps.num_comp_vectors; err_out_unmap: -while (i >=0 ) { -mlx4_free_eq (dev, &priv->eq_table.eq[i]); +while (i >0 ) { --i; +mlx4_free_eq (dev, &priv->eq_table.eq[i]); }mlx4_unmap_clr_int (dev);mlx4_free_irqs (dev);
Quoted 22 lines · Roland Dreier
Quoted 4 lines
If
mlx4_create_eq()would fail for one of EQ's assigned for completion handling, the code would try to free the same EQ we failed to create.
The crash was found by Christoph LameterThanks, good catch. However looking at the code it seems that a simpler way to fix this would be as below. Can you confirm that this works too?
--- drivers/net/mlx4/eq.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)drivers/net/mlx4/eq.c +1
-1@@ -677,12 +677,12 @@ err_out_async:mlx4_free_eq (dev, &priv->eq_table.eq[dev->caps.num_comp_vectors]); err_out_comp: - i = dev->caps.num_comp_vectors -1 ; + i = dev->caps.num_comp_vectors;
drivers/net/mlx4/eq.c err_out_async: · line 688
Quoted 10 lines
drivers/net/mlx4/eq.c +2
-2err_out_unmap: -while (i >=0 ) { -mlx4_free_eq (dev, &priv->eq_table.eq[i]); +while (i >0 ) { --i; +mlx4_free_eq (dev, &priv->eq_table.eq[i]); }mlx4_unmap_clr_int (dev);mlx4_free_irqs (dev);
Yes, it also works
Yevgeny