Skip to contentSkip to conversation

ipv4: fix a memory leak in ic_bootp_send_if

PATCH Applied [email protected] 2 participants 2 messages Nov 14, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: fix a memory leak in ic_bootp_send_if

From: RongQing.Li <[email protected]>

when dev_hard_header() failed, the newly allocated skb should be freed.

---
 net/ipv4/ipconfig.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
net/ipv4/ipconfig.c +7 -2
index 0da2afc..7f17ba8 100644
@@ -822,8 +822,13 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
 	skb->dev = dev;
 	skb->protocol = htons(ETH_P_IP);
 	if (dev_hard_header(skb, dev, ntohs(skb->protocol),
-			    dev->broadcast, dev->dev_addr, skb->len) < 0 ||
-	    dev_queue_xmit(skb) < 0)
+			    dev->broadcast, dev->dev_addr, skb->len) < 0) {
+		kfree_skb(skb);
+		printk("E");
+		return;
+	}
+
+	if (dev_queue_xmit(skb) < 0)
 		printk("E");
 }
 
Signature · 1 line
1.7.1