Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / dsa / dsa.c
index 45295ca095717314294e1be8172a6e852fe1a679..2bc62ea857c8b6842c27ed9d6ee12b564fb2d1e6 100644 (file)
@@ -80,6 +80,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
        int ret;
        char *name;
        int i;
+       bool valid_name_found = false;
 
        /*
         * Probe for switch model.
@@ -131,8 +132,13 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
                } else {
                        ds->phys_port_mask |= 1 << i;
                }
+               valid_name_found = true;
        }
 
+       if (!valid_name_found && i == DSA_MAX_PORTS) {
+               ret = -EINVAL;
+               goto out;
+       }
 
        /*
         * If the CPU connects to this switch, set the switch tree