Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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@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>
Link: https://lore.kernel.org/r/20231006115822.144152-1-o.rempel@pengutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Oleksij Rempel and committed by
Paolo Abeni
59fe6517 c41a38ef

+4 -4
+4 -4
drivers/net/dsa/microchip/ksz9477_acl.c
··· 420 420 return -EINVAL; 421 421 } 422 422 423 - /* Nothing to do */ 424 - if (src_idx == dst_idx) 425 - return 0; 426 - 427 423 /* Validate if the source entries are contiguous */ 428 424 ret = ksz9477_acl_get_cont_entr(dev, port, src_idx); 429 425 if (ret < 0) ··· 551 555 struct ksz9477_acl_priv *acl = dev->ports[port].acl_priv; 552 556 struct ksz9477_acl_entries *acles = &acl->acles; 553 557 int src_count, ret, dst_count; 558 + 559 + /* Nothing to do */ 560 + if (src_idx == dst_idx) 561 + return 0; 554 562 555 563 ret = ksz9477_validate_and_get_src_count(dev, port, src_idx, dst_idx, 556 564 &src_count, &dst_count);