Commit ee6bfc69 authored by Roger Oksanen's avatar Roger Oksanen Committed by Greg Kroah-Hartman

e100: Fix broken cbs accounting due to missing memset.

commit 70abc8cb upstream.

Alan Stern noticed that e100 caused slab corruption.
commit 98468efd changed
the allocation of cbs to use dma pools that don't return zeroed memory,
especially the cb->status field used to track which cb to clean, causing
(the visible) double freeing of skbs and a wrong free cbs count.

Now the cbs are explicitly zeroed at allocation time.
Reported-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Tested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarRoger Oksanen <roger.oksanen@cs.helsinki.fi>
Acked-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ad46fed9
...@@ -1817,6 +1817,7 @@ static int e100_alloc_cbs(struct nic *nic) ...@@ -1817,6 +1817,7 @@ static int e100_alloc_cbs(struct nic *nic)
&nic->cbs_dma_addr); &nic->cbs_dma_addr);
if (!nic->cbs) if (!nic->cbs)
return -ENOMEM; return -ENOMEM;
memset(nic->cbs, 0, count * sizeof(struct cb));
for (cb = nic->cbs, i = 0; i < count; cb++, i++) { for (cb = nic->cbs, i = 0; i < count; cb++, i++) {
cb->next = (i + 1 < count) ? cb + 1 : nic->cbs; cb->next = (i + 1 < count) ? cb + 1 : nic->cbs;
...@@ -1825,7 +1826,6 @@ static int e100_alloc_cbs(struct nic *nic) ...@@ -1825,7 +1826,6 @@ static int e100_alloc_cbs(struct nic *nic)
cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb); cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb);
cb->link = cpu_to_le32(nic->cbs_dma_addr + cb->link = cpu_to_le32(nic->cbs_dma_addr +
((i+1) % count) * sizeof(struct cb)); ((i+1) % count) * sizeof(struct cb));
cb->skb = NULL;
} }
nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs; nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment