Skip to content

Commit 7882c89

Browse files
HoratiuVulturdavem330
authored andcommitted
bridge: mrp: Validate when setting the port role
This patch adds specific checks for primary(0x0) and secondary(0x1) when setting the port role. For any other value the function 'br_mrp_set_port_role' will return -EINVAL. Fixes: 20f6a05 ("bridge: mrp: Rework the MRP netlink interface") Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2464bc7 commit 7882c89

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/bridge/br_mrp.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,16 @@ int br_mrp_set_port_role(struct net_bridge_port *p,
411411
if (!mrp)
412412
return -EINVAL;
413413

414-
if (role == BR_MRP_PORT_ROLE_PRIMARY)
414+
switch (role) {
415+
case BR_MRP_PORT_ROLE_PRIMARY:
415416
rcu_assign_pointer(mrp->p_port, p);
416-
else
417+
break;
418+
case BR_MRP_PORT_ROLE_SECONDARY:
417419
rcu_assign_pointer(mrp->s_port, p);
420+
break;
421+
default:
422+
return -EINVAL;
423+
}
418424

419425
br_mrp_port_switchdev_set_role(p, role);
420426

0 commit comments

Comments
 (0)