Messages in this thread Patch in this message | | | Date | Fri, 31 Dec 2021 14:46:15 -0800 | From | Saeed Mahameed <> | Subject | Re: [PATCH] net/mlx5: Add vport return value checks |
| |
On Thu, Dec 30, 2021 at 01:25:58PM +0800, Zizhuang Deng wrote: >add missing vport return value checks for recent code, as in [1]. > >Ref: >[1] https://lkml.org/lkml/2020/11/1/315 >
Where did this patch come from ? real bug ? or just aligning the code to be according the link below ? because all the use-cases below are supposed to be guaranteed to have a valid vport object for uplink/pf/and ecpf vportrs, i am not against the patch, I am just trying to understand if there is a hidden bug somewhere ..
>Signed-off-by: Zizhuang Deng <sunsetdzz@gmail.com> >--- > .../mellanox/mlx5/core/eswitch_offloads.c | 20 +++++++++++++++++++ > 1 file changed, 20 insertions(+) > >diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c >index f4eaa5893886..fda214021738 100644 >--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c >+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
[...]
>@@ -1309,11 +1317,15 @@ static void esw_del_fdb_peer_miss_rules(struct mlx5_eswitch *esw) > > if (mlx5_ecpf_vport_exists(esw->dev)) { > vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_ECPF); >+ if (IS_ERR(vport)) >+ return;
memleak, we need to hit kvfree(flows) below, instead of returning you should make the del_flow conditional and continue to next steps in the esw_del_fdb_peer_miss_rules routine, e.g: if (vport) mlx5_del_flow_rules(flows[vport->index]);
> mlx5_del_flow_rules(flows[vport->index]); > } > > if (mlx5_core_is_ecpf_esw_manager(esw->dev)) { > vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_PF); >+ if (IS_ERR(vport)) >+ return;
ditto
> mlx5_del_flow_rules(flows[vport->index]); > } > kvfree(flows); >@@ -2385,6 +2397,9 @@ static int esw_set_uplink_slave_ingress_root(struct mlx5_core_dev *master, > if (master) { > esw = master->priv.eswitch; > vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_UPLINK); >+ if (IS_ERR(vport)) >+ return PTR_ERR(vport); >+ > MLX5_SET(set_flow_table_root_in, in, table_of_other_vport, 1); > MLX5_SET(set_flow_table_root_in, in, table_vport_number, > MLX5_VPORT_UPLINK); >@@ -2405,6 +2420,9 @@ static int esw_set_uplink_slave_ingress_root(struct mlx5_core_dev *master, > } else { > esw = slave->priv.eswitch; > vport = mlx5_eswitch_get_vport(esw, MLX5_VPORT_UPLINK); >+ if (IS_ERR(vport)) >+ return PTR_ERR(vport); >+ > ns = mlx5_get_flow_vport_acl_namespace(slave, > MLX5_FLOW_NAMESPACE_ESW_INGRESS, > vport->index); >@@ -2590,6 +2608,8 @@ static void esw_unset_master_egress_rule(struct mlx5_core_dev *dev) > > vport = mlx5_eswitch_get_vport(dev->priv.eswitch, > dev->priv.eswitch->manager_vport); >+ if (IS_ERR(vport)) >+ return; > > esw_acl_egress_ofld_cleanup(vport); > } >-- >2.25.1 >
| |