[PATCH next] net: dsa: print error on invalid port index

Subsystems: networking [dsa], networking [general], the rest

STALE2049d LANDED

Landed in mainline as 8209f5bc3b67 on 2021-01-07.

3 messages, 3 authors, 2021-01-07 · open the first message on its own page

[PATCH next] net: dsa: print error on invalid port index

From: Rafał Miłecki <zajec5@gmail.com>
Date: 2021-01-06 09:10:17

From: Rafał Miłecki <rafal@milecki.pl>

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>
---
 net/dsa/dsa2.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 183003e45762..01f21b0b379a 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -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;
 		}
-- 
2.26.2

Re: [PATCH next] net: dsa: print error on invalid port index

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-01-06 22:33:56

On Wed, Jan 06, 2021 at 10:09:15AM +0100, Rafał Miłecki wrote:
From: Rafał Miłecki <rafal@milecki.pl>

Looking for an -EINVAL all over the dsa code could take hours for
inexperienced DSA users.
Following this argument, you should add dev_err() by every -EINVAL.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

Re: [PATCH next] net: dsa: print error on invalid port index

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-01-07 00:22:40

On Wed, 6 Jan 2021 23:33:07 +0100 Andrew Lunn wrote:
On Wed, Jan 06, 2021 at 10:09:15AM +0100, Rafał Miłecki wrote:
quoted
From: Rafał Miłecki <rafal@milecki.pl>

Looking for an -EINVAL all over the dsa code could take hours for
inexperienced DSA users.  
Following this argument, you should add dev_err() by every -EINVAL.
quoted
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>  
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Applied, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help