generic: rtl8366: prevent modifications of VLAN 0
[openwrt/svn-archive/archive.git] / target / linux / generic-2.6 / files / drivers / net / phy / rtl8366s.c
index babeddc44a717d3ed34b7d523d84a0de5ad0f328..c8e7dd60b52b98a618c848a5b5c0dc3759ef7063 100644 (file)
@@ -1118,7 +1118,7 @@ static int rtl8366s_sw_get_vlan_info(struct switch_dev *dev,
        struct rtl8366s *rtl = sw_to_rtl8366s(dev);
        char *buf = rtl->buf;
 
-       if (val->port_vlan >= RTL8366_NUM_VLANS)
+       if (val->port_vlan == 0 || val->port_vlan >= RTL8366_NUM_VLANS)
                return -EINVAL;
 
        memset(buf, '\0', sizeof(rtl->buf));
@@ -1257,7 +1257,7 @@ static int rtl8366s_sw_get_vlan_ports(struct switch_dev *dev,
        struct switch_port *port;
        int i;
 
-       if (val->port_vlan >= RTL8366_NUM_VLANS)
+       if (val->port_vlan == 0 || val->port_vlan >= RTL8366_NUM_VLANS)
                return -EINVAL;
 
        rtl8366s_get_vlan_member_config(rtl, val->port_vlan, &vlanmc);
@@ -1286,7 +1286,7 @@ static int rtl8366s_sw_set_vlan_ports(struct switch_dev *dev,
        struct switch_port *port;
        int i;
 
-       if (val->port_vlan >= RTL8366_NUM_VLANS)
+       if (val->port_vlan == 0 || val->port_vlan >= RTL8366_NUM_VLANS)
                return -EINVAL;
 
        rtl8366s_get_vlan_member_config(rtl, val->port_vlan, &vlanmc);