[net/wan] cosa_init: check bounds before access

Message ID 20200624010450.4490-1-gaurav1086@gmail.com
State New
Headers show
Series
  • [net/wan] cosa_init: check bounds before access
Related show

Commit Message

Gaurav Singh June 24, 2020, 1:04 a.m.
Check i < io bounds before accessing io[i].

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
---
 drivers/net/wan/cosa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 5d6532ad6b78..8797adfa0ab0 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -363,7 +363,7 @@  static int __init cosa_init(void)
 	}
 	for (i=0; i<MAX_CARDS; i++)
 		cosa_cards[i].num = -1;
-	for (i=0; io[i] != 0 && i < MAX_CARDS; i++)
+	for (i=0; i < MAX_CARDS && io[i] != 0; i++)
 		cosa_probe(io[i], irq[i], dma[i]);
 	if (!nr_cards) {
 		pr_warn("no devices found\n");