提交 6b87663f 编写于 作者: A Arnd Bergmann 提交者: David S. Miller

net/mlx5e: avoid stack overflow in mlx5e_open_channels

struct mlx5e_channel_param is a large structure that is allocated
on the stack of mlx5e_open_channels, and with a recent change
it has grown beyond the warning size for the maximum stack
that a single function should use:

mellanox/mlx5/core/en_main.c: In function 'mlx5e_open_channels':
mellanox/mlx5/core/en_main.c:1325:1: error: the frame size of 1072 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

The function is already using dynamic allocation and is not in
a fast path, so the easiest workaround is to use another kzalloc
for allocating the channel parameters.
Signed-off-by: NArnd Bergmann <arnd@arndb.de>
Fixes: d3c9bc27 ("net/mlx5e: Added ICO SQs")
Acked-by: NSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3df97ba8
...@@ -1245,13 +1245,10 @@ static void mlx5e_build_icosq_param(struct mlx5e_priv *priv, ...@@ -1245,13 +1245,10 @@ static void mlx5e_build_icosq_param(struct mlx5e_priv *priv,
param->icosq = true; param->icosq = true;
} }
static void mlx5e_build_channel_param(struct mlx5e_priv *priv, static void mlx5e_build_channel_param(struct mlx5e_priv *priv, struct mlx5e_channel_param *cparam)
struct mlx5e_channel_param *cparam)
{ {
u8 icosq_log_wq_sz = MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE; u8 icosq_log_wq_sz = MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE;
memset(cparam, 0, sizeof(*cparam));
mlx5e_build_rq_param(priv, &cparam->rq); mlx5e_build_rq_param(priv, &cparam->rq);
mlx5e_build_sq_param(priv, &cparam->sq); mlx5e_build_sq_param(priv, &cparam->sq);
mlx5e_build_icosq_param(priv, &cparam->icosq, icosq_log_wq_sz); mlx5e_build_icosq_param(priv, &cparam->icosq, icosq_log_wq_sz);
...@@ -1262,7 +1259,7 @@ static void mlx5e_build_channel_param(struct mlx5e_priv *priv, ...@@ -1262,7 +1259,7 @@ static void mlx5e_build_channel_param(struct mlx5e_priv *priv,
static int mlx5e_open_channels(struct mlx5e_priv *priv) static int mlx5e_open_channels(struct mlx5e_priv *priv)
{ {
struct mlx5e_channel_param cparam; struct mlx5e_channel_param *cparam;
int nch = priv->params.num_channels; int nch = priv->params.num_channels;
int err = -ENOMEM; int err = -ENOMEM;
int i; int i;
...@@ -1274,12 +1271,15 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv) ...@@ -1274,12 +1271,15 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv)
priv->txq_to_sq_map = kcalloc(nch * priv->params.num_tc, priv->txq_to_sq_map = kcalloc(nch * priv->params.num_tc,
sizeof(struct mlx5e_sq *), GFP_KERNEL); sizeof(struct mlx5e_sq *), GFP_KERNEL);
if (!priv->channel || !priv->txq_to_sq_map) cparam = kzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL);
if (!priv->channel || !priv->txq_to_sq_map || !cparam)
goto err_free_txq_to_sq_map; goto err_free_txq_to_sq_map;
mlx5e_build_channel_param(priv, &cparam); mlx5e_build_channel_param(priv, cparam);
for (i = 0; i < nch; i++) { for (i = 0; i < nch; i++) {
err = mlx5e_open_channel(priv, i, &cparam, &priv->channel[i]); err = mlx5e_open_channel(priv, i, cparam, &priv->channel[i]);
if (err) if (err)
goto err_close_channels; goto err_close_channels;
} }
...@@ -1290,6 +1290,7 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv) ...@@ -1290,6 +1290,7 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv)
goto err_close_channels; goto err_close_channels;
} }
kfree(cparam);
return 0; return 0;
err_close_channels: err_close_channels:
...@@ -1299,6 +1300,7 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv) ...@@ -1299,6 +1300,7 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv)
err_free_txq_to_sq_map: err_free_txq_to_sq_map:
kfree(priv->txq_to_sq_map); kfree(priv->txq_to_sq_map);
kfree(priv->channel); kfree(priv->channel);
kfree(cparam);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册