Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netem: fix possible skb leak

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 <edumazet@google.com>
Cc: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
116a0fc3 e072b3fa

+2 -4
+2 -4
net/sched/sch_netem.c
··· 408 408 if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) { 409 409 if (!(skb = skb_unshare(skb, GFP_ATOMIC)) || 410 410 (skb->ip_summed == CHECKSUM_PARTIAL && 411 - skb_checksum_help(skb))) { 412 - sch->qstats.drops++; 413 - return NET_XMIT_DROP; 414 - } 411 + skb_checksum_help(skb))) 412 + return qdisc_drop(skb, sch); 415 413 416 414 skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); 417 415 }