diff mbox series

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

Message ID 20210106090915.21439-1-zajec5@gmail.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [next] net: dsa: print error on invalid port index | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Rafał Miłecki Jan. 6, 2021, 9:09 a.m. UTC
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(+)

Comments

Andrew Lunn Jan. 6, 2021, 10:33 p.m. UTC | #1
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
Jakub Kicinski Jan. 7, 2021, 12:21 a.m. UTC | #2
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:
> > 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>

Applied, thanks!
diff mbox series

Patch

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;
 		}