Commit 90ac2458 authored by Eli Cohen's avatar Eli Cohen Committed by Saeed Mahameed

net/mlx5e: Remove redundant pointer check

When code reaches the "out" label, n is guaranteed to be valid so we can
unconditionally call neigh_release.

Also change the label to release_neigh to better reflect the fact that
we unconditionally free the neighbour and also match other labels
convention.
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent e689e998
...@@ -236,13 +236,13 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, ...@@ -236,13 +236,13 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
mlx5_core_warn(priv->mdev, "encap size %d too big, max supported is %d\n", mlx5_core_warn(priv->mdev, "encap size %d too big, max supported is %d\n",
ipv4_encap_size, max_encap_size); ipv4_encap_size, max_encap_size);
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
goto out; goto release_neigh;
} }
encap_header = kzalloc(ipv4_encap_size, GFP_KERNEL); encap_header = kzalloc(ipv4_encap_size, GFP_KERNEL);
if (!encap_header) { if (!encap_header) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto release_neigh;
} }
/* used by mlx5e_detach_encap to lookup a neigh hash table /* used by mlx5e_detach_encap to lookup a neigh hash table
...@@ -294,7 +294,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, ...@@ -294,7 +294,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
/* the encap entry will be made valid on neigh update event /* the encap entry will be made valid on neigh update event
* and not used before that. * and not used before that.
*/ */
goto out; goto release_neigh;
} }
e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev, e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev,
e->reformat_type, e->reformat_type,
...@@ -314,8 +314,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, ...@@ -314,8 +314,7 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e); mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
free_encap: free_encap:
kfree(encap_header); kfree(encap_header);
out: release_neigh:
if (n)
neigh_release(n); neigh_release(n);
return err; return err;
} }
...@@ -355,13 +354,13 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, ...@@ -355,13 +354,13 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
mlx5_core_warn(priv->mdev, "encap size %d too big, max supported is %d\n", mlx5_core_warn(priv->mdev, "encap size %d too big, max supported is %d\n",
ipv6_encap_size, max_encap_size); ipv6_encap_size, max_encap_size);
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
goto out; goto release_neigh;
} }
encap_header = kzalloc(ipv6_encap_size, GFP_KERNEL); encap_header = kzalloc(ipv6_encap_size, GFP_KERNEL);
if (!encap_header) { if (!encap_header) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto release_neigh;
} }
/* used by mlx5e_detach_encap to lookup a neigh hash table /* used by mlx5e_detach_encap to lookup a neigh hash table
...@@ -412,7 +411,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, ...@@ -412,7 +411,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
/* the encap entry will be made valid on neigh update event /* the encap entry will be made valid on neigh update event
* and not used before that. * and not used before that.
*/ */
goto out; goto release_neigh;
} }
e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev, e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev,
...@@ -433,8 +432,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, ...@@ -433,8 +432,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e); mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
free_encap: free_encap:
kfree(encap_header); kfree(encap_header);
out: release_neigh:
if (n)
neigh_release(n); neigh_release(n);
return err; return err;
} }
......
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