[PATCH] net: alx: fix possible buffer overflow

From: Alexander A. Klimov

Date: Wed May 20 2026 - 15:03:27 EST


In alx_request_msix(), use snprintf(DST, sizeof(DST), ...)
and not sprintf(DST, ...) to never write more than sizeof(DST) bytes.

Fixes: e0eac2546090 ("alx: prepare interrupt functions for multiple queues")
Signed-off-by: Alexander A. Klimov <grandmaster@xxxxxxxxxxxx>
---
drivers/net/ethernet/atheros/alx/main.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index ab262e66f986..d2697d9eacfa 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -865,16 +865,17 @@ static int alx_request_msix(struct alx_priv *alx)
vector++;

if (np->txq && np->rxq)
- sprintf(np->irq_lbl, "%s-TxRx-%u", netdev->name,
- np->txq->queue_idx);
+ snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-TxRx-%u",
+ netdev->name, np->txq->queue_idx);
else if (np->txq)
- sprintf(np->irq_lbl, "%s-tx-%u", netdev->name,
- np->txq->queue_idx);
+ snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-tx-%u",
+ netdev->name, np->txq->queue_idx);
else if (np->rxq)
- sprintf(np->irq_lbl, "%s-rx-%u", netdev->name,
- np->rxq->queue_idx);
+ snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-rx-%u",
+ netdev->name, np->rxq->queue_idx);
else
- sprintf(np->irq_lbl, "%s-unused", netdev->name);
+ snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-unused",
+ netdev->name);

np->vec_idx = vector;
err = request_irq(pci_irq_vector(alx->hw.pdev, vector),
--
2.54.0