Skip to content

Commit

Permalink
net/mlx5: Fix invalid pointer reference when prof_sel parameter is in…
Browse files Browse the repository at this point in the history
…valid

When prof_sel is invalid, mlx5_core_warn is called but the
mlx5_core_dev is not initialized yet. Solution is moving the prof_sel code
after dev->pdev assignment

Fixes: 2974ab6 ('net/mlx5: Improve driver log messages')
Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Huy Nguyen authored and David S. Miller committed Nov 4, 2016
1 parent ee39fbc commit 0e97a34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/mellanox/mlx5/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,15 +1226,16 @@ static int init_one(struct pci_dev *pdev,

pci_set_drvdata(pdev, dev);

dev->pdev = pdev;
dev->event = mlx5_core_event;

if (prof_sel < 0 || prof_sel >= ARRAY_SIZE(profile)) {
mlx5_core_warn(dev,
"selected profile out of range, selecting default (%d)\n",
MLX5_DEFAULT_PROF);
prof_sel = MLX5_DEFAULT_PROF;
}
dev->profile = &profile[prof_sel];
dev->pdev = pdev;
dev->event = mlx5_core_event;

INIT_LIST_HEAD(&priv->ctx_list);
spin_lock_init(&priv->ctx_lock);
Expand Down

0 comments on commit 0e97a34

Please sign in to comment.