Skip to content

Commit 4de20e9

Browse files
w1ldptrSaeed Mahameed
authored andcommitted
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: Vlad Buslov <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent ec60c45 commit 4de20e9

File tree

1 file changed

+9
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/esw

1 file changed

+9
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,10 +1042,8 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa
10421042
int err;
10431043

10441044
port = kvzalloc(sizeof(*port), GFP_KERNEL);
1045-
if (!port) {
1046-
err = -ENOMEM;
1047-
goto err_port_alloc;
1048-
}
1045+
if (!port)
1046+
return -ENOMEM;
10491047

10501048
port->vport_num = vport->vport;
10511049
xa_init(&port->vlans);
@@ -1062,8 +1060,6 @@ static int mlx5_esw_bridge_vport_init(struct mlx5_esw_bridge_offloads *br_offloa
10621060

10631061
err_port_insert:
10641062
kvfree(port);
1065-
err_port_alloc:
1066-
mlx5_esw_bridge_put(br_offloads, bridge);
10671063
return err;
10681064
}
10691065

@@ -1108,8 +1104,14 @@ int mlx5_esw_bridge_vport_link(int ifindex, struct mlx5_esw_bridge_offloads *br_
11081104
}
11091105

11101106
err = mlx5_esw_bridge_vport_init(br_offloads, bridge, vport);
1111-
if (err)
1107+
if (err) {
11121108
NL_SET_ERR_MSG_MOD(extack, "Error initializing port");
1109+
goto err_vport;
1110+
}
1111+
return 0;
1112+
1113+
err_vport:
1114+
mlx5_esw_bridge_put(br_offloads, bridge);
11131115
return err;
11141116
}
11151117

0 commit comments

Comments
 (0)