]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
bridge: tunnel: fix attribute checks in br_parse_vlan_tunnel_info
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Tue, 7 Feb 2017 11:46:46 +0000 (12:46 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Feb 2017 19:05:30 +0000 (14:05 -0500)
These checks should go after the attributes have been parsed otherwise
we're using tb uninitialized.

Fixes: efa5356b0d97 ("bridge: per vlan dst_metadata netlink support")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_netlink_tunnel.c

index 99c68012c9d4c2dc8e9dafc9cb8b1777dc21b7a1..62eaf750bd9e1866fa5c39e8caf5f6df7c612b97 100644 (file)
@@ -229,15 +229,15 @@ int br_parse_vlan_tunnel_info(struct nlattr *attr,
 
        memset(tinfo, 0, sizeof(*tinfo));
 
-       if (!tb[IFLA_BRIDGE_VLAN_TUNNEL_ID] ||
-           !tb[IFLA_BRIDGE_VLAN_TUNNEL_VID])
-               return -EINVAL;
-
        err = nla_parse_nested(tb, IFLA_BRIDGE_VLAN_TUNNEL_MAX,
                               attr, vlan_tunnel_policy);
        if (err < 0)
                return err;
 
+       if (!tb[IFLA_BRIDGE_VLAN_TUNNEL_ID] ||
+           !tb[IFLA_BRIDGE_VLAN_TUNNEL_VID])
+               return -EINVAL;
+
        tun_id = nla_get_u32(tb[IFLA_BRIDGE_VLAN_TUNNEL_ID]);
        vid = nla_get_u16(tb[IFLA_BRIDGE_VLAN_TUNNEL_VID]);
        if (vid >= VLAN_VID_MASK)