summaryrefslogtreecommitdiff
path: root/include/net/dsa.h
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@gmail.com>2019-10-25 21:48:53 +0300
committerDavid S. Miller <davem@davemloft.net>2019-10-29 22:07:49 +0300
commitd607525bd912860aad137326a1076d1e9880ddf0 (patch)
tree86c282a61aa3a8b9c1859b25592c6cbb7a550414 /include/net/dsa.h
parent92d72f1b8bbbd87220daa49cd1253ce72bb7553c (diff)
downloadlinux-d607525bd912860aad137326a1076d1e9880ddf0.tar.xz
net: dsa: return directly from dsa_to_port
Return directly from within the loop as soon as the port is found, otherwise we won't return NULL if the end of the list is reached. Fixes: b96ddf254b09 ("net: dsa: use ports list in dsa_to_port") Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index d5f6e5ccca38..9aba326abb64 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -283,13 +283,13 @@ struct dsa_switch {
static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
{
struct dsa_switch_tree *dst = ds->dst;
- struct dsa_port *dp = NULL;
+ struct dsa_port *dp;
list_for_each_entry(dp, &dst->ports, list)
if (dp->ds == ds && dp->index == p)
- break;
+ return dp;
- return dp;
+ return NULL;
}
static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)