Commit 4de20e9a authored by Vlad Buslov's avatar Vlad Buslov Committed by Saeed Mahameed

net/mlx5: Bridge, release bridge in same function where it is taken

Refactor mlx5_esw_bridge_vport_link() to release the bridge instance if
mlx5_esw_bridge_vport_init() returned an error instead of relying on it to
release the bridge. This improves the design because object instance is
taken and released in same layer and simplifies following patches that add
more logic to mlx5_esw_bridge_vport_link().
Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent ec60c458
......@@ -1042,10 +1042,8 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa
int err;
port = kvzalloc(sizeof(*port), GFP_KERNEL);
if (!port) {
err = -ENOMEM;
goto err_port_alloc;
}
if (!port)
return -ENOMEM;
port->vport_num = vport->vport;
xa_init(&port->vlans);
......@@ -1062,8 +1060,6 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa
err_port_insert:
kvfree(port);
err_port_alloc:
mlx5_esw_bridge_put(br_offloads, bridge);
return err;
}
......@@ -1108,8 +1104,14 @@ int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_
}
err = mlx5_esw_bridge_vport_init(br_offloads, bridge, vport);
if (err)
if (err) {
NL_SET_ERR_MSG_MOD(extack, "Error initializing port");
goto err_vport;
}
return 0;
err_vport:
mlx5_esw_bridge_put(br_offloads, bridge);
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