Patchwork ipv4: fix a memory leak in ic_bootp_send_if

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date Nov. 14, 2011, 7:54 a.m.
Message ID <1321257248-14175-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/125499/
State Accepted
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - Nov. 14, 2011, 7:54 a.m.
From: RongQing.Li <roy.qing.li@gmail.com>

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

Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>
---
 net/ipv4/ipconfig.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
David Miller - Nov. 14, 2011, 7:38 p.m.
From: roy.qing.li@gmail.com
Date: Mon, 14 Nov 2011 15:54:08 +0800

> From: RongQing.Li <roy.qing.li@gmail.com>
> 
> when dev_hard_header() failed, the newly allocated skb should be freed.
> 
> Signed-off-by: RongQing.Li <roy.qing.li@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 0da2afc..7f17ba8 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -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");
 }