From: Julia Lawall Date: Thu, 28 Jul 2011 02:46:03 +0000 (+0000) Subject: drivers/net/niu.c: adjust array index X-Git-Tag: firefly_0821_release~7541^2~2974 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b1d3755791db359c3827c59248d9aa5f5f430931;p=firefly-linux-kernel-4.4.55.git drivers/net/niu.c: adjust array index [ Upstream commit 956837f7c954443f426a82ba6f17b33488cf9a0c ] Convert array index from the loop bound to the loop index. A simplified version of the semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression e1,e2,ar; @@ for(e1 = 0; e1 < e2; e1++) { <... ar[ - e2 + e1 ] ...> } // Signed-off-by: Julia Lawall Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/niu.c b/drivers/net/niu.c index cc25bff0bd3b..2f8c351b1173 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c @@ -9196,7 +9196,7 @@ static int __devinit niu_ldg_init(struct niu *np) first_chan = 0; for (i = 0; i < port; i++) - first_chan += parent->rxchan_per_port[port]; + first_chan += parent->rxchan_per_port[i]; num_chan = parent->rxchan_per_port[port]; for (i = first_chan; i < (first_chan + num_chan); i++) { @@ -9212,7 +9212,7 @@ static int __devinit niu_ldg_init(struct niu *np) first_chan = 0; for (i = 0; i < port; i++) - first_chan += parent->txchan_per_port[port]; + first_chan += parent->txchan_per_port[i]; num_chan = parent->txchan_per_port[port]; for (i = first_chan; i < (first_chan + num_chan); i++) { err = niu_ldg_assign_ldn(np, parent,