[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A7C494B.2060204@gmail.com>
Date: Fri, 07 Aug 2009 17:33:31 +0200
From: Roel Kluin <roel.kluin@...il.com>
To: netdev@...r.kernel.org, Andrew Morton <akpm@...ux-foundation.org>,
"David S. Miller" <davem@...emloft.net>, n0-1@...ewrt.org,
florian@...nwrt.org
Subject: [PATCH] korina: Read buffer overflow
If the loop breaks with an i of 0, then we read lp->rd_ring[-1].
Signed-off-by: Roel Kluin <roel.kluin@...il.com>
---
Should we clean up like this? please review
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index b4cf602..b965b2b 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -754,7 +754,7 @@ static void korina_alloc_ring(struct net_device *dev)
{
struct korina_private *lp = netdev_priv(dev);
struct sk_buff *skb;
- int i;
+ int i, j;
/* Initialize the transmit descriptors */
for (i = 0; i < KORINA_NUM_TDS; i++) {
@@ -771,7 +771,7 @@ static void korina_alloc_ring(struct net_device *dev)
for (i = 0; i < KORINA_NUM_RDS; i++) {
skb = dev_alloc_skb(KORINA_RBSIZE + 2);
if (!skb)
- break;
+ goto err_free;
skb_reserve(skb, 2);
lp->rx_skb[i] = skb;
lp->rd_ring[i].control = DMA_DESC_IOD |
@@ -790,6 +790,12 @@ static void korina_alloc_ring(struct net_device *dev)
lp->rx_chain_head = 0;
lp->rx_chain_tail = 0;
lp->rx_chain_status = desc_empty;
+err_free:
+ for (j = 0; j < i; j++) {
+ lp->rd_ring[j].control = 0;
+ dev_kfree_skb_any(lp->rx_skb[j]);
+ lp->rx_skb[j] = NULL;
+ }
}
static void korina_free_ring(struct net_device *dev)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists