Commit 61c5652a authored by Kambo Lohan's avatar Kambo Lohan Committed by David S. Miller

[NET]: Fix hang/memleak in pktgen.

parent 03eb6d11
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
* Also moved to /proc/net/pktgen/ * Also moved to /proc/net/pktgen/
* --ro * --ro
* *
* Fix refcount off by one if first packet fails, potential null deref,
* memleak 030710- KJP
*
* See Documentation/networking/pktgen.txt for how to use this. * See Documentation/networking/pktgen.txt for how to use this.
*/ */
...@@ -85,9 +88,9 @@ ...@@ -85,9 +88,9 @@
#define cycles() ((u32)get_cycles()) #define cycles() ((u32)get_cycles())
#define VERSION "pktgen version 1.2" #define VERSION "pktgen version 1.2.1"
static char version[] __initdata = static char version[] __initdata =
"pktgen.c: v1.2: Packet Generator for packet performance testing.\n"; "pktgen.c: v1.2.1: Packet Generator for packet performance testing.\n";
/* Used to help with determining the pkts on receive */ /* Used to help with determining the pkts on receive */
...@@ -611,12 +614,11 @@ static void inject(struct pktgen_info* info) ...@@ -611,12 +614,11 @@ static void inject(struct pktgen_info* info)
kfree_skb(skb); kfree_skb(skb);
skb = fill_packet(odev, info); skb = fill_packet(odev, info);
if (skb == NULL) { if (skb == NULL) {
break; goto out_reldev;
} }
fp++; fp++;
fp_tmp = 0; /* reset counter */ fp_tmp = 0; /* reset counter */
} }
atomic_inc(&skb->users);
} }
nr_frags = skb_shinfo(skb)->nr_frags; nr_frags = skb_shinfo(skb)->nr_frags;
...@@ -624,7 +626,11 @@ static void inject(struct pktgen_info* info) ...@@ -624,7 +626,11 @@ static void inject(struct pktgen_info* info)
spin_lock_bh(&odev->xmit_lock); spin_lock_bh(&odev->xmit_lock);
if (!netif_queue_stopped(odev)) { if (!netif_queue_stopped(odev)) {
atomic_inc(&skb->users);
if (odev->hard_start_xmit(skb, odev)) { if (odev->hard_start_xmit(skb, odev)) {
atomic_dec(&skb->users);
if (net_ratelimit()) { if (net_ratelimit()) {
printk(KERN_INFO "Hard xmit error\n"); printk(KERN_INFO "Hard xmit error\n");
} }
...@@ -730,6 +736,8 @@ static void inject(struct pktgen_info* info) ...@@ -730,6 +736,8 @@ static void inject(struct pktgen_info* info)
); );
} }
kfree_skb(skb);
out_reldev: out_reldev:
if (odev) { if (odev) {
dev_put(odev); dev_put(odev);
......
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