提交 66e2809d 编写于 作者: A Andrew Lunn 提交者: David S. Miller

net: dsa: mv88e6xxx: Fix opps when adding vlan bridge

A port is not necessarily assigned to a netdev. And a port does not
need to be a member of a bridge. So when iterating over all ports,
check before using the netdev and bridge_dev for a port. Otherwise we
dereference a NULL pointer.

Fixes: da9c359e ("net: dsa: mv88e6xxx: check hardware VLAN in use")
Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
Reviewed-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 e28ceeb1
...@@ -1775,6 +1775,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, ...@@ -1775,6 +1775,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
continue; continue;
if (!ds->ports[port].netdev)
continue;
if (vlan.data[i] == if (vlan.data[i] ==
GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER) GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
continue; continue;
...@@ -1783,6 +1786,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, ...@@ -1783,6 +1786,9 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
chip->ports[port].bridge_dev) chip->ports[port].bridge_dev)
break; /* same bridge, check next VLAN */ break; /* same bridge, check next VLAN */
if (!chip->ports[i].bridge_dev)
continue;
netdev_warn(ds->ports[port].netdev, netdev_warn(ds->ports[port].netdev,
"hardware VLAN %d already used by %s\n", "hardware VLAN %d already used by %s\n",
vlan.vid, vlan.vid,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册