[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231006115822.144152-1-o.rempel@pengutronix.de>
Date: Fri, 6 Oct 2023 13:58:22 +0200
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: "David S. Miller" <davem@...emloft.net>,
Andrew Lunn <andrew@...n.ch>,
Eric Dumazet <edumazet@...gle.com>,
Florian Fainelli <f.fainelli@...il.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Vladimir Oltean <olteanv@...il.com>,
Woojung Huh <woojung.huh@...rochip.com>,
Arun Ramadoss <arun.ramadoss@...rochip.com>,
"Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>,
Dan Carpenter <dan.carpenter@...aro.org>,
kernel@...gutronix.de,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org,
UNGLinuxDriver@...rochip.com,
Petr Machata <petrm@...dia.com>,
Lukasz Majewski <lukma@...x.de>
Subject: [PATCH net-next v1 1/1] net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries()
Address an issue in ksz9477_acl_move_entries() where, in the scenario
(src_idx == dst_idx), ksz9477_validate_and_get_src_count() returns 0,
leading to usage of uninitialized src_count and dst_count variables,
which causes undesired behavior as it attempts to move ACL entries
around.
Fixes: 002841be134e ("net: dsa: microchip: Add partial ACL support for ksz9477 switches")
Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
Suggested-by: Vladimir Oltean <olteanv@...il.com>
Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
---
drivers/net/dsa/microchip/ksz9477_acl.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz9477_acl.c b/drivers/net/dsa/microchip/ksz9477_acl.c
index 06d74c19eb94..7ba778df63ac 100644
--- a/drivers/net/dsa/microchip/ksz9477_acl.c
+++ b/drivers/net/dsa/microchip/ksz9477_acl.c
@@ -420,10 +420,6 @@ static int ksz9477_validate_and_get_src_count(struct ksz_device *dev, int port,
return -EINVAL;
}
- /* Nothing to do */
- if (src_idx == dst_idx)
- return 0;
-
/* Validate if the source entries are contiguous */
ret = ksz9477_acl_get_cont_entr(dev, port, src_idx);
if (ret < 0)
@@ -556,6 +552,10 @@ static int ksz9477_acl_move_entries(struct ksz_device *dev, int port,
struct ksz9477_acl_entries *acles = &acl->acles;
int src_count, ret, dst_count;
+ /* Nothing to do */
+ if (src_idx == dst_idx)
+ return 0;
+
ret = ksz9477_validate_and_get_src_count(dev, port, src_idx, dst_idx,
&src_count, &dst_count);
if (ret)
--
2.39.2
Powered by blists - more mailing lists