aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2013-02-25 03:22:26 -0500
committerDavid S. Miller <davem@davemloft.net>2013-02-25 15:47:41 -0500
commit70a737b795d1d2fa0c1b54b8b7870c86cedd03ac (patch)
tree12cd5ccb6317cf8e328c184c2328eedf91eb1832 /drivers/net
parent63a02ce1c5c59baa40b99756492e3ec8d6b51483 (diff)
bgmac: fix indexing of 2nd level loops
We were using the same variable for iterating two nested loops. Reported-by: Tijs Van Buggenhout <tvb@able.be> Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/broadcom/bgmac.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 3fd32880e526..bf985c04524e 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -436,6 +436,8 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
436 } 436 }
437 437
438 for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) { 438 for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) {
439 int j;
440
439 ring = &bgmac->rx_ring[i]; 441 ring = &bgmac->rx_ring[i];
440 ring->num_slots = BGMAC_RX_RING_SLOTS; 442 ring->num_slots = BGMAC_RX_RING_SLOTS;
441 ring->mmio_base = ring_base[i]; 443 ring->mmio_base = ring_base[i];
@@ -458,8 +460,8 @@ static int bgmac_dma_alloc(struct bgmac *bgmac)
458 bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n"); 460 bgmac_warn(bgmac, "DMA address using 0xC0000000 bit(s), it may need translation trick\n");
459 461
460 /* Alloc RX slots */ 462 /* Alloc RX slots */
461 for (i = 0; i < ring->num_slots; i++) { 463 for (j = 0; j < ring->num_slots; j++) {
462 err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[i]); 464 err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
463 if (err) { 465 if (err) {
464 bgmac_err(bgmac, "Can't allocate skb for slot in RX ring\n"); 466 bgmac_err(bgmac, "Can't allocate skb for slot in RX ring\n");
465 goto err_dma_free; 467 goto err_dma_free;
@@ -496,6 +498,8 @@ static void bgmac_dma_init(struct bgmac *bgmac)
496 } 498 }
497 499
498 for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) { 500 for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) {
501 int j;
502
499 ring = &bgmac->rx_ring[i]; 503 ring = &bgmac->rx_ring[i];
500 504
501 /* We don't implement unaligned addressing, so enable first */ 505 /* We don't implement unaligned addressing, so enable first */
@@ -505,11 +509,11 @@ static void bgmac_dma_init(struct bgmac *bgmac)
505 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGHI, 509 bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_RINGHI,
506 upper_32_bits(ring->dma_base)); 510 upper_32_bits(ring->dma_base));
507 511
508 for (i = 0, dma_desc = ring->cpu_base; i < ring->num_slots; 512 for (j = 0, dma_desc = ring->cpu_base; j < ring->num_slots;
509 i++, dma_desc++) { 513 j++, dma_desc++) {
510 ctl0 = ctl1 = 0; 514 ctl0 = ctl1 = 0;
511 515
512 if (i == ring->num_slots - 1) 516 if (j == ring->num_slots - 1)
513 ctl0 |= BGMAC_DESC_CTL0_EOT; 517 ctl0 |= BGMAC_DESC_CTL0_EOT;
514 ctl1 |= BGMAC_RX_BUF_SIZE & BGMAC_DESC_CTL1_LEN; 518 ctl1 |= BGMAC_RX_BUF_SIZE & BGMAC_DESC_CTL1_LEN;
515 /* Is there any BGMAC device that requires extension? */ 519 /* Is there any BGMAC device that requires extension? */
@@ -517,8 +521,8 @@ static void bgmac_dma_init(struct bgmac *bgmac)
517 * B43_DMA64_DCTL1_ADDREXT_MASK; 521 * B43_DMA64_DCTL1_ADDREXT_MASK;
518 */ 522 */
519 523
520 dma_desc->addr_low = cpu_to_le32(lower_32_bits(ring->slots[i].dma_addr)); 524 dma_desc->addr_low = cpu_to_le32(lower_32_bits(ring->slots[j].dma_addr));
521 dma_desc->addr_high = cpu_to_le32(upper_32_bits(ring->slots[i].dma_addr)); 525 dma_desc->addr_high = cpu_to_le32(upper_32_bits(ring->slots[j].dma_addr));
522 dma_desc->ctl0 = cpu_to_le32(ctl0); 526 dma_desc->ctl0 = cpu_to_le32(ctl0);
523 dma_desc->ctl1 = cpu_to_le32(ctl1); 527 dma_desc->ctl1 = cpu_to_le32(ctl1);
524 } 528 }