Skip to content

Commit

Permalink
IB/mlx4: Fix mlx4_ib_add() error flow
Browse files Browse the repository at this point in the history
We need to use a different loop index for mlx4_counter_alloc() and for
device_create_file() iterations: the mlx4_counter_alloc() loop index
is used in the error flow to free counters.

If the same loop index is used for device_create_file() and, say, the
device_create_file() loop fails on the first iteration, the allocated
counters will not be freed.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
  • Loading branch information
Jack Morgenstein authored and Roland Dreier committed May 19, 2012
1 parent e605b74 commit 035b103
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/infiniband/hw/mlx4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
{
struct mlx4_ib_dev *ibdev;
int num_ports = 0;
int i;
int i, j;
int err;
struct mlx4_ib_iboe *iboe;

Expand Down Expand Up @@ -1323,9 +1323,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
goto err_reg;
}

for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) {
for (j = 0; j < ARRAY_SIZE(mlx4_class_attributes); ++j) {
if (device_create_file(&ibdev->ib_dev.dev,
mlx4_class_attributes[i]))
mlx4_class_attributes[j]))
goto err_notif;
}

Expand Down

0 comments on commit 035b103

Please sign in to comment.