diff options
author | Matt Carlson <mcarlson@broadcom.com> | 2012-04-24 09:37:01 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-21 12:40:00 -0400 |
commit | bdffb470b07b026cf8d1e83d07085f335dae8eac (patch) | |
tree | 56c4ccb77d10038975b92e4599214a4e8765de6d /drivers/net | |
parent | 53a67da1360b5634779e1cfece9625ae5b32aba7 (diff) |
tg3: Avoid panic from reserved statblk field access
[ Upstream commit f891ea1634ce41f5f47ae40d8594809f4cd2ca66 ]
When RSS is enabled, interrupt vector 0 does not receive any rx traffic.
The rx producer index fields for vector 0's status block should be
considered reserved in this case. This patch changes the code to
respect these reserved fields, which avoids a kernel panic when these
fields take on non-zero values.
Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/tg3.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index bc8c183d622..c4ab8a721b4 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -740,8 +740,13 @@ static inline unsigned int tg3_has_work(struct tg3_napi *tnapi) | |||
740 | if (sblk->status & SD_STATUS_LINK_CHG) | 740 | if (sblk->status & SD_STATUS_LINK_CHG) |
741 | work_exists = 1; | 741 | work_exists = 1; |
742 | } | 742 | } |
743 | /* check for RX/TX work to do */ | 743 | |
744 | if (sblk->idx[0].tx_consumer != tnapi->tx_cons || | 744 | /* check for TX work to do */ |
745 | if (sblk->idx[0].tx_consumer != tnapi->tx_cons) | ||
746 | work_exists = 1; | ||
747 | |||
748 | /* check for RX work to do */ | ||
749 | if (tnapi->rx_rcb_prod_idx && | ||
745 | *(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr) | 750 | *(tnapi->rx_rcb_prod_idx) != tnapi->rx_rcb_ptr) |
746 | work_exists = 1; | 751 | work_exists = 1; |
747 | 752 | ||
@@ -5216,6 +5221,9 @@ static int tg3_poll_work(struct tg3_napi *tnapi, int work_done, int budget) | |||
5216 | return work_done; | 5221 | return work_done; |
5217 | } | 5222 | } |
5218 | 5223 | ||
5224 | if (!tnapi->rx_rcb_prod_idx) | ||
5225 | return work_done; | ||
5226 | |||
5219 | /* run RX thread, within the bounds set by NAPI. | 5227 | /* run RX thread, within the bounds set by NAPI. |
5220 | * All RX "locking" is done by ensuring outside | 5228 | * All RX "locking" is done by ensuring outside |
5221 | * code synchronizes with tg3->napi.poll() | 5229 | * code synchronizes with tg3->napi.poll() |
@@ -6626,6 +6634,12 @@ static int tg3_alloc_consistent(struct tg3 *tp) | |||
6626 | */ | 6634 | */ |
6627 | switch (i) { | 6635 | switch (i) { |
6628 | default: | 6636 | default: |
6637 | if (tg3_flag(tp, ENABLE_RSS)) { | ||
6638 | tnapi->rx_rcb_prod_idx = NULL; | ||
6639 | break; | ||
6640 | } | ||
6641 | /* Fall through */ | ||
6642 | case 1: | ||
6629 | tnapi->rx_rcb_prod_idx = &sblk->idx[0].rx_producer; | 6643 | tnapi->rx_rcb_prod_idx = &sblk->idx[0].rx_producer; |
6630 | break; | 6644 | break; |
6631 | case 2: | 6645 | case 2: |