Skip to content

Commit

Permalink
netem: fix possible skb leak
Browse files Browse the repository at this point in the history
skb_checksum_help(skb) can return an error, we must free skb in this
case. qdisc_drop(skb, sch) can also be feeded with a NULL skb (if
skb_unshare() failed), so lets use this generic helper.

Signed-off-by: Eric Dumazet <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed May 1, 2012
1 parent e072b3f commit 116a0fc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/sched/sch_netem.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
(skb->ip_summed == CHECKSUM_PARTIAL &&
skb_checksum_help(skb))) {
sch->qstats.drops++;
return NET_XMIT_DROP;
}
skb_checksum_help(skb)))
return qdisc_drop(skb, sch);

skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
}
Expand Down

0 comments on commit 116a0fc

Please sign in to comment.