diff mbox series

[net-next,v1,1/1] net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries()

Message ID 20231006115822.144152-1-o.rempel@pengutronix.de (mailing list archive)
State Accepted
Commit 59fe651753fb897ebe0ac91c19cf503e7a551632
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1,1/1] net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1362 this patch: 1362
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang fail Errors and warnings before: 17 this patch: 17
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn fail Errors and warnings before: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Oleksij Rempel Oct. 6, 2023, 11:58 a.m. UTC
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@linaro.org>
Suggested-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz9477_acl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Florian Fainelli Oct. 6, 2023, 5:24 p.m. UTC | #1
On 10/6/23 04:58, Oleksij Rempel wrote:
> 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@linaro.org>
> Suggested-by: Vladimir Oltean <olteanv@gmail.com>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
patchwork-bot+netdevbpf@kernel.org Oct. 10, 2023, 9:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri,  6 Oct 2023 13:58:22 +0200 you wrote:
> 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@linaro.org>
> Suggested-by: Vladimir Oltean <olteanv@gmail.com>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> 
> [...]

Here is the summary with links:
  - [net-next,v1,1/1] net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries()
    https://git.kernel.org/netdev/net-next/c/59fe651753fb

You are awesome, thank you!
diff mbox series

Patch

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)