Commit 811bb1b9 authored by Arkadi Sharshevsky's avatar Arkadi Sharshevsky Committed by Greg Kroah-Hartman

mlxsw: switchx2: Fix memory leak at skb reallocation

[ Upstream commit 400fc010 ]

During transmission the skb is checked for headroom in order to
add vendor specific header. In case the skb needs to be re-allocated,
skb_realloc_headroom() is called to make a private copy of the original,
but doesn't release it. Current code assumes that the original skb is
released during reallocation and only releases it at the error path
which causes a memory leak.

Fix this by adding the original skb release to the main path.

Fixes: d003462a ("mlxsw: Simplify mlxsw_sx_port_xmit function")
Signed-off-by: default avatarArkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9edb2d75
...@@ -313,6 +313,7 @@ static netdev_tx_t mlxsw_sx_port_xmit(struct sk_buff *skb, ...@@ -313,6 +313,7 @@ static netdev_tx_t mlxsw_sx_port_xmit(struct sk_buff *skb,
dev_kfree_skb_any(skb_orig); dev_kfree_skb_any(skb_orig);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
dev_consume_skb_any(skb_orig);
} }
mlxsw_sx_txhdr_construct(skb, &tx_info); mlxsw_sx_txhdr_construct(skb, &tx_info);
len = skb->len; len = skb->len;
......
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