[Patch] net: fix an array index overflow

From: Amerigo Wang
Date: Tue Dec 01 2009 - 03:26:11 EST



Don't use the address of an out-of-boundary element.

Maybe this is not harmful at runtime, but it is still
good to improve it.

Signed-off-by: WANG Cong <amwang@xxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>

---
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 57737b8..2669361 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1586,7 +1586,7 @@ static int __init inet_init(void)
#endif

/* Register the socket-side information for inet_create. */
- for (r = &inetsw[0]; r < &inetsw[SOCK_MAX]; ++r)
+ for (r = &inetsw[0]; r <= &inetsw[SOCK_MAX-1]; ++r)
INIT_LIST_HEAD(r);

for (q = inetsw_array; q < &inetsw_array[INETSW_ARRAY_LEN]; ++q)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/