diff options
author | Nicu Ioan Petru <ionut.nicu@freescale.com> | 2007-04-13 02:26:29 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 11:01:05 -0400 |
commit | 3a8205ead4dc4b05fbc164eeb852b8f8921d11d3 (patch) | |
tree | d78277465c1a5bfc31f2855145da5715ed2648f3 /drivers | |
parent | d5b9049df25f38b3eaf3af48d494b0747aae4349 (diff) |
ucc_geth: fixes for ucc_geth_memclean
The ucc_geth_memclean function can be called before the Tx BD rings, Rx
BD rings and associated socket buffers are allocated (for example if
ucc_fast_init fails). The current code doesn't check if p_tx_bd_ring[i]
is null, generating a kernel panic when trying to free the associated
socket buffers.
The function can also fail when accessing the uninitialized list_head
structures ugeth->group_hash_q and ugeth->ind_hash_q. In the current
implementation the list heads are initialized only when
maxGroupAddrInHash and maxIndAddrInHash are positive values, although I
think it's better to always initialize them.
Signed-off-by: Ionut Nicu <ionut.nicu@freescale.com>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ucc_geth.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 60844a6f4928..20bc105bcbc9 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -2133,6 +2133,8 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth) | |||
2133 | } | 2133 | } |
2134 | for (i = 0; i < ugeth->ug_info->numQueuesTx; i++) { | 2134 | for (i = 0; i < ugeth->ug_info->numQueuesTx; i++) { |
2135 | bd = ugeth->p_tx_bd_ring[i]; | 2135 | bd = ugeth->p_tx_bd_ring[i]; |
2136 | if (!bd) | ||
2137 | continue; | ||
2136 | for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { | 2138 | for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { |
2137 | if (ugeth->tx_skbuff[i][j]) { | 2139 | if (ugeth->tx_skbuff[i][j]) { |
2138 | dma_unmap_single(NULL, | 2140 | dma_unmap_single(NULL, |
@@ -2300,6 +2302,10 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth) | |||
2300 | ug_info = ugeth->ug_info; | 2302 | ug_info = ugeth->ug_info; |
2301 | uf_info = &ug_info->uf_info; | 2303 | uf_info = &ug_info->uf_info; |
2302 | 2304 | ||
2305 | /* Create CQs for hash tables */ | ||
2306 | INIT_LIST_HEAD(&ugeth->group_hash_q); | ||
2307 | INIT_LIST_HEAD(&ugeth->ind_hash_q); | ||
2308 | |||
2303 | if (!((uf_info->bd_mem_part == MEM_PART_SYSTEM) || | 2309 | if (!((uf_info->bd_mem_part == MEM_PART_SYSTEM) || |
2304 | (uf_info->bd_mem_part == MEM_PART_MURAM))) { | 2310 | (uf_info->bd_mem_part == MEM_PART_MURAM))) { |
2305 | ugeth_err("%s: Bad memory partition value.", __FUNCTION__); | 2311 | ugeth_err("%s: Bad memory partition value.", __FUNCTION__); |
@@ -3132,13 +3138,6 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
3132 | for (j = 0; j < NUM_OF_PADDRS; j++) | 3138 | for (j = 0; j < NUM_OF_PADDRS; j++) |
3133 | ugeth_82xx_filtering_clear_addr_in_paddr(ugeth, (u8) j); | 3139 | ugeth_82xx_filtering_clear_addr_in_paddr(ugeth, (u8) j); |
3134 | 3140 | ||
3135 | /* Create CQs for hash tables */ | ||
3136 | if (ug_info->maxGroupAddrInHash > 0) { | ||
3137 | INIT_LIST_HEAD(&ugeth->group_hash_q); | ||
3138 | } | ||
3139 | if (ug_info->maxIndAddrInHash > 0) { | ||
3140 | INIT_LIST_HEAD(&ugeth->ind_hash_q); | ||
3141 | } | ||
3142 | p_82xx_addr_filt = | 3141 | p_82xx_addr_filt = |
3143 | (struct ucc_geth_82xx_address_filtering_pram *) ugeth-> | 3142 | (struct ucc_geth_82xx_address_filtering_pram *) ugeth-> |
3144 | p_rx_glbl_pram->addressfiltering; | 3143 | p_rx_glbl_pram->addressfiltering; |