Patchwork pktgen: fix skb leak in case of failure

login
register
mail settings
Submitter Ilpo Järvinen
Date Oct. 13, 2008, 2:22 p.m.
Message ID <Pine.LNX.4.64.0810131657250.3843@wrl-59.cs.helsinki.fi>
Download mbox | patch
Permalink /patch/4269/
State Accepted
Delegated to: David Miller
Headers show

Comments

Patch

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index fcb1031..b6b2a8e 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2474,7 +2474,7 @@  static inline int process_ipsec(struct pktgen_dev *pkt_dev,
 				if (ret < 0) {
 					printk(KERN_ERR "Error expanding "
 					       "ipsec packet %d\n",ret);
-					return 0;
+					goto err;
 				}
 			}
 
@@ -2484,8 +2484,7 @@  static inline int process_ipsec(struct pktgen_dev *pkt_dev,
 			if (ret) {
 				printk(KERN_ERR "Error creating ipsec "
 				       "packet %d\n",ret);
-				kfree_skb(skb);
-				return 0;
+				goto err;
 			}
 			/* restore ll */
 			eth = (__u8 *) skb_push(skb, ETH_HLEN);
@@ -2494,6 +2493,9 @@  static inline int process_ipsec(struct pktgen_dev *pkt_dev,
 		}
 	}
 	return 1;
+err:
+	kfree_skb(skb);
+	return 0;
 }
 #endif