OSDN Git Service

net: dsa: ksz: fix skb freeing
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Wed, 9 Aug 2017 20:46:09 +0000 (16:46 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Aug 2017 20:57:08 +0000 (13:57 -0700)
commite71cb9e00922902ba0519f37d09145f117dc02b3
tree67606720f7ba689059f4e67eb9d5f0a09d1468c6
parent26273939ace935dd7553b31d279eab30b40f7b9a
net: dsa: ksz: fix skb freeing

The DSA layer frees the original skb when an xmit function returns NULL,
meaning an error occurred. But if the tagging code copied the original
skb, it is responsible of freeing the copy if an error occurs.

The ksz tagging code currently has two issues: if skb_put_padto fails,
the skb copy is not freed, and the original skb will be freed twice.

To fix that, move skb_put_padto inside both branches of the skb_tailroom
condition, before freeing the original skb, and free the copy on error.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Woojung Huh <woojung.huh@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/tag_ksz.c