[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191025184853.1375840-1-vivien.didelot@gmail.com>
Date: Fri, 25 Oct 2019 14:48:53 -0400
From: Vivien Didelot <vivien.didelot@...il.com>
To: "David S. Miller" <davem@...emloft.net>
Cc: Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
netdev@...r.kernel.org, Vivien Didelot <vivien.didelot@...il.com>
Subject: [PATCH net-next] 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@...il.com>
---
include/net/dsa.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 73900b89c1b9..14357b576b13 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -286,13 +286,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)
--
2.23.0
Powered by blists - more mailing lists