Skip to content

Commit

Permalink
net: dsa: print error on invalid port index
Browse files Browse the repository at this point in the history
Looking for an -EINVAL all over the dsa code could take hours for
inexperienced DSA users.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20210106090915.21439-1-zajec5@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Rafał Miłecki authored and Jakub Kicinski committed Jan 7, 2021
1 parent ede71ca commit 8209f5b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/dsa/dsa2.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
goto out_put_node;

if (reg >= ds->num_ports) {
dev_err(ds->dev, "port %pOF index %u exceeds num_ports (%zu)\n",
port, reg, ds->num_ports);
err = -EINVAL;
goto out_put_node;
}
Expand Down

0 comments on commit 8209f5b

Please sign in to comment.