Skip to content

Commit 0d961b3

Browse files
hsdenxdavem330
authored andcommitted
drivers: net: cpsw: fix buggy loop condition
Commit 0cd8f9c ("drivers: net: cpsw: enable promiscuous mode support") Enable promiscuous mode support for CPSW. Introduced a crash on an am335x based board (similiar to am335x-evm). Reason is buggy end condition in for loop in cpsw_set_promiscious() for (i = 0; i <= priv->data.slaves; i++) should be for (i = 0; i < priv->data.slaves; i++) Fix this ... Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Mugunthan V N <mugunthanvnm@ti.com> Cc: David S. Miller <davem@davemloft.net> Cc: Sebastian Siewior <bigeasy@linutronix.de> Cc: Daniel Mack <zonque@gmail.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Markus Pargmann <mpa@pengutronix.de> Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b0c057c commit 0d961b3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
554554
* common for both the interface as the interface shares
555555
* the same hardware resource.
556556
*/
557-
for (i = 0; i <= priv->data.slaves; i++)
557+
for (i = 0; i < priv->data.slaves; i++)
558558
if (priv->slaves[i].ndev->flags & IFF_PROMISC)
559559
flag = true;
560560

@@ -578,7 +578,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
578578
unsigned long timeout = jiffies + HZ;
579579

580580
/* Disable Learn for all ports */
581-
for (i = 0; i <= priv->data.slaves; i++) {
581+
for (i = 0; i < priv->data.slaves; i++) {
582582
cpsw_ale_control_set(ale, i,
583583
ALE_PORT_NOLEARN, 1);
584584
cpsw_ale_control_set(ale, i,
@@ -606,7 +606,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
606606
cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0);
607607

608608
/* Enable Learn for all ports */
609-
for (i = 0; i <= priv->data.slaves; i++) {
609+
for (i = 0; i < priv->data.slaves; i++) {
610610
cpsw_ale_control_set(ale, i,
611611
ALE_PORT_NOLEARN, 0);
612612
cpsw_ale_control_set(ale, i,

0 commit comments

Comments
 (0)