]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mlxsw: spectrum: Fix memory leak at skb reallocation
authorArkadi Sharshevsky <arkadis@mellanox.com>
Thu, 12 Jan 2017 08:10:37 +0000 (09:10 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Jan 2017 14:25:55 +0000 (09:25 -0500)
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: 56ade8fe3fe1 ("mlxsw: spectrum: Add initial support for Spectrum ASIC")
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c

index d768c7b6c6d6688c46077c48e25df45cdf9ad7dc..003093abb1707f0a6cdefe465e073c005d2ee3f9 100644 (file)
@@ -684,6 +684,7 @@ static netdev_tx_t mlxsw_sp_port_xmit(struct sk_buff *skb,
                        dev_kfree_skb_any(skb_orig);
                        return NETDEV_TX_OK;
                }
+               dev_consume_skb_any(skb_orig);
        }
 
        if (eth_skb_pad(skb)) {