Commit 71129676 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Saeed Mahameed

net/mlx5e: Return the allocated flow directly from __mlx5e_add_fdb_flow

This confusing construction confuses the compiler which can't see
that flow is initialized if !err:

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c: In function `mlx5e_configure_flower`
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:2727:28: warning:
`flow` may be used uninitialized in this function
[-Wmaybe-uninitialized]

There is no reason for two function outputs, just return the
pointer directly and use ERR_PTR to encode a failure.
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 149e566f
...@@ -2767,14 +2767,13 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size, ...@@ -2767,14 +2767,13 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
return err; return err;
} }
static int static struct mlx5e_tc_flow *
__mlx5e_add_fdb_flow(struct mlx5e_priv *priv, __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
struct tc_cls_flower_offload *f, struct tc_cls_flower_offload *f,
u16 flow_flags, u16 flow_flags,
struct net_device *filter_dev, struct net_device *filter_dev,
struct mlx5_eswitch_rep *in_rep, struct mlx5_eswitch_rep *in_rep,
struct mlx5_core_dev *in_mdev, struct mlx5_core_dev *in_mdev)
struct mlx5e_tc_flow **__flow)
{ {
struct netlink_ext_ack *extack = f->common.extack; struct netlink_ext_ack *extack = f->common.extack;
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
...@@ -2814,15 +2813,13 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv, ...@@ -2814,15 +2813,13 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
if (err) if (err)
goto err_free; goto err_free;
*__flow = flow; return flow;
return 0;
err_free: err_free:
kfree(flow); kfree(flow);
kvfree(parse_attr); kvfree(parse_attr);
out: out:
return err; return ERR_PTR(err);
} }
static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f, static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f,
...@@ -2855,11 +2852,13 @@ static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f, ...@@ -2855,11 +2852,13 @@ static int mlx5e_tc_add_fdb_peer_flow(struct tc_cls_flower_offload *f,
in_mdev = priv->mdev; in_mdev = priv->mdev;
parse_attr = flow->esw_attr->parse_attr; parse_attr = flow->esw_attr->parse_attr;
err = __mlx5e_add_fdb_flow(peer_priv, f, flow->flags, peer_flow = __mlx5e_add_fdb_flow(peer_priv, f, flow->flags,
parse_attr->filter_dev, parse_attr->filter_dev,
flow->esw_attr->in_rep, in_mdev, &peer_flow); flow->esw_attr->in_rep, in_mdev);
if (err) if (IS_ERR(peer_flow)) {
err = PTR_ERR(peer_flow);
goto out; goto out;
}
flow->peer_flow = peer_flow; flow->peer_flow = peer_flow;
flow->flags |= MLX5E_TC_FLOW_DUP; flow->flags |= MLX5E_TC_FLOW_DUP;
...@@ -2885,10 +2884,10 @@ mlx5e_add_fdb_flow(struct mlx5e_priv *priv, ...@@ -2885,10 +2884,10 @@ mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow; struct mlx5e_tc_flow *flow;
int err; int err;
err = __mlx5e_add_fdb_flow(priv, f, flow_flags, filter_dev, in_rep, flow = __mlx5e_add_fdb_flow(priv, f, flow_flags, filter_dev, in_rep,
in_mdev, &flow); in_mdev);
if (err) if (IS_ERR(flow))
goto out; return PTR_ERR(flow);
if (is_peer_flow_needed(flow)) { if (is_peer_flow_needed(flow)) {
err = mlx5e_tc_add_fdb_peer_flow(f, flow); err = mlx5e_tc_add_fdb_peer_flow(f, flow);
......
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