Message ID | 20200728091035.112067-2-saeedm@mellanox.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | [net,01/12] net/mlx5e: Hold reference on mirred devices while accessing them | expand |
On Tue, Jul 28, 2020 at 12:13 PM Saeed Mahameed <saeedm@mellanox.com> wrote: > From: Eli Cohen <eli@mellanox.com> > > Net devices might be removed. For example, a vxlan device could be > deleted and its ifnidex would become invalid. Use dev_get_by_index() > instead of __dev_get_by_index() to hold reference on the device while > accessing it and release after done. haven't this patch sent in the past in the same form and we were in the middle of discussing how to properly address this? if something changed, what?
On Tue, 2020-07-28 at 13:27 +0300, Or Gerlitz wrote: > On Tue, Jul 28, 2020 at 12:13 PM Saeed Mahameed <saeedm@mellanox.com> > wrote: > > From: Eli Cohen <eli@mellanox.com> > > > > Net devices might be removed. For example, a vxlan device could be > > deleted and its ifnidex would become invalid. Use > > dev_get_by_index() > > instead of __dev_get_by_index() to hold reference on the device > > while > > accessing it and release after done. > > haven't this patch sent in the past in the same form and we were in > the middle > of discussing how to properly address this? if something changed, > what? I thought the discussion was concluded ? anyway i will remove this patch from my trees, Eli please discuss with Or, i am fine with this patch as is since it is a minimal fix to net.
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index cc8412151ca09..518957d82b1ca 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -1327,10 +1327,14 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, continue; mirred_ifindex = parse_attr->mirred_ifindex[out_index]; - out_dev = __dev_get_by_index(dev_net(priv->netdev), - mirred_ifindex); + out_dev = dev_get_by_index(dev_net(priv->netdev), + mirred_ifindex); + if (!out_dev) + return -ENODEV; + err = mlx5e_attach_encap(priv, flow, out_dev, out_index, extack, &encap_dev, &encap_valid); + dev_put(out_dev); if (err) return err;