[PATCH net-next 06/13] net/mlx5: LAG, size debugfs buffers by port count
From: Tariq Toukan
Date: Wed Sep 23 2026 - 06:57:59 EST
From: Shay Drory <shayd@xxxxxxxxxx>
debugfs mapping_show() uses constant MLX5_MAX_PORTS to size ports array.
Instead, allocate dynamically using actual number of ports.
Signed-off-by: Shay Drory <shayd@xxxxxxxxxx>
Reviewed-by: Moshe Shemesh <moshe@xxxxxxxxxx>
Reviewed-by: Akiva Goldberger <agoldberger@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c
index e9b8d79d2d21..44296789d656 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c
@@ -101,14 +101,18 @@ static int flags_show(struct seq_file *file, void *priv)
static int mapping_show(struct seq_file *file, void *priv)
{
struct mlx5_core_dev *dev = file->private;
- u8 ports[MLX5_MAX_PORTS] = {};
struct mlx5_lag *ldev;
bool hash = false;
bool lag_active;
int i, idx = 0;
int num_ports;
+ u8 *ports;
ldev = mlx5_lag_dev(dev);
+ ports = kcalloc(ldev->ports, sizeof(*ports), GFP_KERNEL);
+ if (!ports)
+ return -ENOMEM;
+
mutex_lock(&ldev->lock);
lag_active = __mlx5_lag_is_active(ldev);
if (lag_active) {
@@ -123,8 +127,10 @@ static int mapping_show(struct seq_file *file, void *priv)
}
}
mutex_unlock(&ldev->lock);
- if (!lag_active)
+ if (!lag_active) {
+ kfree(ports);
return -EINVAL;
+ }
for (i = 0; i < num_ports; i++) {
if (hash)
@@ -133,6 +139,7 @@ static int mapping_show(struct seq_file *file, void *priv)
seq_printf(file, "%d:%d\n", i + 1, ports[i]);
}
+ kfree(ports);
return 0;
}
--
2.44.0