mlxsw: switchx2: Fix memory leak at skb reallocation
authorArkadi Sharshevsky <arkadis@mellanox.com>
Thu, 12 Jan 2017 08:10:38 +0000 (09:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Feb 2017 08:45:08 +0000 (09:45 +0100)
commit811bb1b9d9ab0ac6bfdb9ae3fb7596e604114e31
treec446f066ced55fafc42031b4f94faadb1a735c6c
parent9edb2d75d81be37a79d0fa84b0a7d5c5f4880b89
mlxsw: switchx2: Fix memory leak at skb reallocation

[ Upstream commit 400fc0106dd8c27ed84781c929c1a184785b9c79 ]

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: d003462a50de ("mlxsw: Simplify mlxsw_sx_port_xmit function")
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/mellanox/mlxsw/switchx2.c