Skip to content

Commit 3338beb

Browse files
Binary-Eaterkuba-moo
authored andcommitted
net/mlx5: Increase size of irq name buffer
Without increased buffer size, will trigger -Wformat-truncation with W=1 for the snprintf operation writing to the buffer. drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c: In function 'mlx5_irq_alloc': drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c:296:7: error: '@pci:' directive output may be truncated writing 5 bytes into a region of size between 1 and 32 [-Werror=format-truncation=] 296 | "%s@pci:%s", name, pci_name(dev->pdev)); | ^~~~~ drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c:295:2: note: 'snprintf' output 6 or more bytes (assuming 37) into a destination of size 32 295 | snprintf(irq->name, MLX5_MAX_IRQ_NAME, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 296 | "%s@pci:%s", name, pci_name(dev->pdev)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: ada9f5d ("IB/mlx5: Fix eq names to display nicely in /proc/interrupts") Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6d4ab2e97dcfbcd748ae71761a9d8e5e41cc732c Signed-off-by: Rahul Rameshbabu <[email protected]> Reviewed-by: Dragos Tatulea <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 92214be commit 3338beb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
struct mlx5_irq {
2929
struct atomic_notifier_head nh;
3030
cpumask_var_t mask;
31-
char name[MLX5_MAX_IRQ_NAME];
31+
char name[MLX5_MAX_IRQ_FORMATTED_NAME];
3232
struct mlx5_irq_pool *pool;
3333
int refcount;
3434
struct msi_map map;
@@ -292,8 +292,8 @@ struct mlx5_irq *mlx5_irq_alloc(struct mlx5_irq_pool *pool, int i,
292292
else
293293
irq_sf_set_name(pool, name, i);
294294
ATOMIC_INIT_NOTIFIER_HEAD(&irq->nh);
295-
snprintf(irq->name, MLX5_MAX_IRQ_NAME,
296-
"%s@pci:%s", name, pci_name(dev->pdev));
295+
snprintf(irq->name, MLX5_MAX_IRQ_FORMATTED_NAME,
296+
MLX5_IRQ_NAME_FORMAT_STR, name, pci_name(dev->pdev));
297297
err = request_irq(irq->map.virq, irq_int_handler, 0, irq->name,
298298
&irq->nh);
299299
if (err) {

drivers/net/ethernet/mellanox/mlx5/core/pci_irq.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include <linux/mlx5/driver.h>
88

99
#define MLX5_MAX_IRQ_NAME (32)
10+
#define MLX5_IRQ_NAME_FORMAT_STR ("%s@pci:%s")
11+
#define MLX5_MAX_IRQ_FORMATTED_NAME \
12+
(MLX5_MAX_IRQ_NAME + sizeof(MLX5_IRQ_NAME_FORMAT_STR))
1013
/* max irq_index is 2047, so four chars */
1114
#define MLX5_MAX_IRQ_IDX_CHARS (4)
1215
#define MLX5_EQ_REFS_PER_IRQ (2)

0 commit comments

Comments
 (0)