Re: [PATCH net-next 09/13] net: dsa: lantiq_gswip: Forbid gswip_add_single_port_br on the CPU port

From: Martin Schiller
Date: Fri Jun 07 2024 - 09:34:21 EST


On 2024-06-07 13:26, Vladimir Oltean wrote:
On Thu, Jun 06, 2024 at 10:52:30AM +0200, Martin Schiller wrote:
From: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>

Calling gswip_add_single_port_br() with the CPU port would be a bug
because then only the CPU port could talk to itself. Add the CPU port to
the validation at the beginning of gswip_add_single_port_br().

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>
---
drivers/net/dsa/lantiq_gswip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index ee8296d5b901..d2195271ffe9 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -657,7 +657,7 @@ static int gswip_add_single_port_br(struct gswip_priv *priv, int port, bool add)
unsigned int max_ports = priv->hw_info->max_ports;
int err;

- if (port >= max_ports) {
+ if (port >= max_ports || dsa_is_cpu_port(priv->ds, port)) {
dev_err(priv->dev, "single port for %i supported\n", port);
return -EIO;
}
--
2.39.2


Isn't the new check effectively dead code?

As long as the dsa_switch_ops .port_bridge_join and .port_bridge_leave are not
executed for the cpu port, I agree with you.