* [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels
@ 2016-04-26 15:52 Arnd Bergmann
[not found] ` <1461685993-1049370-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2016-04-28 20:47 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2016-04-26 15:52 UTC (permalink / raw)
To: Saeed Mahameed, Matan Barak, Leon Romanovsky
Cc: Arnd Bergmann, David S. Miller, Achiad Shochat, Or Gerlitz,
Amir Vadai, Tariq Toukan, netdev, linux-rdma, linux-kernel
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: Arnd Bergmann <arnd@arndb.de>
Fixes: d3c9bc2743dc ("net/mlx5e: Added ICO SQs")
---
v2: move allocation back into caller, as suggested by Saeed Mahameed
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index af8c54d2e99c..7106006c792b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1266,13 +1266,10 @@ static void mlx5e_build_icosq_param(struct mlx5e_priv *priv,
param->icosq = true;
}
-static void mlx5e_build_channel_param(struct mlx5e_priv *priv,
- struct mlx5e_channel_param *cparam)
+static void mlx5e_build_channel_param(struct mlx5e_priv *priv, struct mlx5e_channel_param *cparam)
{
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_sq_param(priv, &cparam->sq);
mlx5e_build_icosq_param(priv, &cparam->icosq, icosq_log_wq_sz);
@@ -1283,7 +1280,7 @@ static void mlx5e_build_channel_param(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 err = -ENOMEM;
int i;
@@ -1295,12 +1292,15 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv)
priv->txq_to_sq_map = kcalloc(nch * priv->params.num_tc,
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;
- mlx5e_build_channel_param(priv, &cparam);
+ mlx5e_build_channel_param(priv, cparam);
+
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)
goto err_close_channels;
}
@@ -1311,6 +1311,7 @@ static int mlx5e_open_channels(struct mlx5e_priv *priv)
goto err_close_channels;
}
+ kfree(cparam);
return 0;
err_close_channels:
@@ -1320,6 +1321,7 @@ err_close_channels:
err_free_txq_to_sq_map:
kfree(priv->txq_to_sq_map);
kfree(priv->channel);
+ kfree(cparam);
return err;
}
--
2.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels
2016-04-26 15:52 [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels Arnd Bergmann
@ 2016-04-26 18:52 ` Saeed Mahameed
2016-04-28 20:47 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Saeed Mahameed @ 2016-04-26 18:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Saeed Mahameed, Matan Barak, Leon Romanovsky, David S. Miller,
Achiad Shochat, Or Gerlitz, Amir Vadai, Tariq Toukan,
Linux Netdev List, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Tue, Apr 26, 2016 at 6:52 PM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> 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: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> Fixes: d3c9bc2743dc ("net/mlx5e: Added ICO SQs")
Acked-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels
@ 2016-04-26 18:52 ` Saeed Mahameed
0 siblings, 0 replies; 4+ messages in thread
From: Saeed Mahameed @ 2016-04-26 18:52 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Saeed Mahameed, Matan Barak, Leon Romanovsky, David S. Miller,
Achiad Shochat, Or Gerlitz, Amir Vadai, Tariq Toukan,
Linux Netdev List, linux-rdma, linux-kernel
On Tue, Apr 26, 2016 at 6:52 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> 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: Arnd Bergmann <arnd@arndb.de>
> Fixes: d3c9bc2743dc ("net/mlx5e: Added ICO SQs")
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels
2016-04-26 15:52 [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels Arnd Bergmann
[not found] ` <1461685993-1049370-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
@ 2016-04-28 20:47 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-04-28 20:47 UTC (permalink / raw)
To: arnd
Cc: saeedm, matanb, leonro, achiad, ogerlitz, amir, tariqt, netdev,
linux-rdma, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 26 Apr 2016 17:52:33 +0200
> 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: Arnd Bergmann <arnd@arndb.de>
> Fixes: d3c9bc2743dc ("net/mlx5e: Added ICO SQs")
> ---
> v2: move allocation back into caller, as suggested by Saeed Mahameed
Applied, thanks Arnd.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-28 20:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26 15:52 [PATCH v2] net/mlx5e: avoid stack overflow in mlx5e_open_channels Arnd Bergmann
[not found] ` <1461685993-1049370-1-git-send-email-arnd-r2nGTMty4D4@public.gmane.org>
2016-04-26 18:52 ` Saeed Mahameed
2016-04-26 18:52 ` Saeed Mahameed
2016-04-28 20:47 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.