net/mlx5e: Fix possible memory leak
authorWei Yongjun <weiyongjun1@huawei.com>
Thu, 18 May 2017 15:34:41 +0000 (15:34 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 May 2017 19:18:31 +0000 (15:18 -0400)
'encap_header' is malloced and should be freed before leaving from
the error handling cases, otherwise it will cause memory leak.

Fixes: 232c001398ae ("net/mlx5e: Add support to neighbour update flow")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index 11c27e4fadf6e09400a432c5498749df73265477..a72ecbc27f851ff6fd24fe92a06bfaec18f9c606 100644 (file)
@@ -1404,8 +1404,8 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
 
        if (!(nud_state & NUD_VALID)) {
                neigh_event_send(n, NULL);
-               neigh_release(n);
-               return -EAGAIN;
+               err = -EAGAIN;
+               goto out;
        }
 
        err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,
@@ -1510,8 +1510,8 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
 
        if (!(nud_state & NUD_VALID)) {
                neigh_event_send(n, NULL);
-               neigh_release(n);
-               return -EAGAIN;
+               err = -EAGAIN;
+               goto out;
        }
 
        err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,