net/mlx5e: Protect encap route dev from concurrent release
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx5 / core / en / rep / tc.c
index e36e505..d29af7b 100644 (file)
@@ -107,12 +107,16 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
                mlx5e_tc_encap_flows_del(priv, e, &flow_list);
 
        if (neigh_connected && !(e->flags & MLX5_ENCAP_ENTRY_VALID)) {
+               struct net_device *route_dev;
+
                ether_addr_copy(e->h_dest, ha);
                ether_addr_copy(eth->h_dest, ha);
                /* Update the encap source mac, in case that we delete
                 * the flows when encap source mac changed.
                 */
-               ether_addr_copy(eth->h_source, e->route_dev->dev_addr);
+               route_dev = __dev_get_by_index(dev_net(priv->netdev), e->route_dev_ifindex);
+               if (route_dev)
+                       ether_addr_copy(eth->h_source, route_dev->dev_addr);
 
                mlx5e_tc_encap_flows_add(priv, e, &flow_list);
        }