Commit dfe35fa73e531c9ce88d2fbdb5bd5716e9c190e6

Authored by Thadeu Lima de Souza Cascardo
Committed by Greg Kroah-Hartman
1 parent 1ea1f33931

tg3: fix ring init when there are more TX than RX channels

[ Upstream commit a620a6bc1c94c22d6c312892be1e0ae171523125 ]

If TX channels are set to 4 and RX channels are set to less than 4,
using ethtool -L, the driver will try to initialize more RX channels
than it has allocated, causing an oops.

This fix only initializes the RX ring if it has been allocated.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

drivers/net/ethernet/broadcom/tg3.c
... ... @@ -8548,7 +8548,8 @@
8548 8548 if (tnapi->rx_rcb)
8549 8549 memset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
8550 8550  
8551   - if (tg3_rx_prodring_alloc(tp, &tnapi->prodring)) {
  8551 + if (tnapi->prodring.rx_std &&
  8552 + tg3_rx_prodring_alloc(tp, &tnapi->prodring)) {
8552 8553 tg3_free_rings(tp);
8553 8554 return -ENOMEM;
8554 8555 }