netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: fealnx: fix possible 'card_idx' integer overflow in
@ 2025-12-11 17:30 Ilya Krutskih
  2025-12-12  9:45 ` Simon Horman
  2025-12-12 11:30 ` kernel test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Ilya Krutskih @ 2025-12-11 17:30 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Ilya Krutskih, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Thomas Gleixner, Ingo Molnar, netdev, linux-kernel,
	lvc-project, stable

'card_idx' can be overflowed when fealnx_init_one() will be called more than
INT_MAX times. Check before incremention is required.

Fixes: 15c037d6423e ("fealnx: Move the Myson driver")
Cc: stable@vger.kernel.org # v5.10+
Signed-off-by: Ilya Krutskih <devsec@tpz.ru>
---
 drivers/net/ethernet/fealnx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
index 6ac8547ef9b8..7eb6e42b4551 100644
--- a/drivers/net/ethernet/fealnx.c
+++ b/drivers/net/ethernet/fealnx.c
@@ -489,7 +489,10 @@ static int fealnx_init_one(struct pci_dev *pdev,
 	int bar = 1;
 #endif
 
-	card_idx++;
+	if (card_idx == INT_MAX)
+		return -EINVAL;
+	else
+		card_idx++;
 	sprintf(boardname, "fealnx%d", card_idx);
 
 	option = card_idx < MAX_UNITS ? options[card_idx] : 0;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-12-13  0:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 17:30 [PATCH v2] net: fealnx: fix possible 'card_idx' integer overflow in Ilya Krutskih
2025-12-12  9:45 ` Simon Horman
2025-12-12 11:30 ` kernel test robot
2025-12-12 14:46   ` Simon Horman
2025-12-12 17:36     ` David Laight
2025-12-13  0:21       ` Francois Romieu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).