Skip to contentSkip to conversation

netxen: fix the ring interrupt name buffer

PATCH Applied xujiahao 2 participants 2 messages Nov 6 – Nov 11

Subsystems (3)
lore
Share & tools
lore

xujiahao

author
#0 lore raw

PATCH 1/1 netxen: fix the ring interrupt name buffer

The receive ring interrupt names are assembled with sprintf() into IFNAMSIZ + 4 byte buffers as "%s[%d]", with netdev->name (up to IFNAMSIZ - 1 characters) and the ring index. A 15-character name plus "[" and a full-range %d needs 28 bytes, so gcc reports in a W=1 build:

drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c:1052:45: warning: '%d' directive writing between 1 and 11 bytes into a region of size between 4 and 19 [-Wformat-overflow=]

Enlarge the buffer so the worst case fits and switch to snprintf() so that the write can never exceed it either way.

---
 drivers/net/ethernet/qlogic/netxen/netxen_nic.h      | 2 +-
 drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/netxen/netxen_nic.h +1 -1
index 3d36d23df..1b924b2d5 100644
@@ -634,7 +634,7 @@ struct nx_host_sds_ring {
 	int irq;
 
 	dma_addr_t phys_addr;
-	char name[IFNAMSIZ+4];
+	char name[IFNAMSIZ + 16];
 };
 
 struct nx_host_tx_ring {
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +2 -1
index 67d9bf69f..cffa93a98 100644
@@ -1049,7 +1049,8 @@ netxen_nic_request_irq(struct netxen_adapter *adapter)
 
 	for (ring = 0; ring < adapter->max_sds_rings; ring++) {
 		sds_ring = &recv_ctx->sds_rings[ring];
-		sprintf(sds_ring->name, "%s[%d]", netdev->name, ring);
+		snprintf(sds_ring->name, sizeof(sds_ring->name),
+			 "%s[%d]", netdev->name, ring);
 		err = request_irq(sds_ring->irq, handler,
 				  flags, sds_ring->name, sds_ring);
 		if (err)
Signature · 1 line
2.43.0
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Dave Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Dave Miller <[email protected]>:

Quoted 8 lines · On Fri, 6 Nov 2026 17:51:15 +0800 you wrote:

The receive ring interrupt names are assembled with sprintf() into IFNAMSIZ + 4 byte buffers as "%s[%d]", with netdev->name (up to IFNAMSIZ - 1 characters) and the ring index. A 15-character name plus "[" and a full-range %d needs 28 bytes, so gcc reports in a W=1 build:

drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c:1052:45: warning: '%d' directive writing between 1 and 11 bytes into a region of size between 4 and 19 [-Wformat-overflow=]

[...]

Here is the summary with links:
- [net-next] netxen: fix the ring interrupt name buffer

    https://git.kernel.org/netdev/net-next/c/c40c6c365183

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html