[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 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp265309vqo; Fri, 6 Oct 2023 04:58:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtR3+PrtWHyDdoNAvNlP9zhJgyIjIk9KPouwuJMi5ZI0XoQF+1QYKhAwIW6EPJyoacADhT X-Received: by 2002:a17:902:e810:b0:1c5:59ea:84de with SMTP id u16-20020a170902e81000b001c559ea84demr9523592plg.29.1696593532951; Fri, 06 Oct 2023 04:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696593532; cv=none; d=google.com; s=arc-20160816; b=L+KEVu9jip0N0o06a24i3nqux9lebrjMJ6XJHpq/h8A9XFd3aGWGTbSfpuGs3ABqco RQ4JrDFihm8T7AQpvY1zumIh54UOHjo09QNnX/8s23yb5B5XpYMiBKI2E5CYVjnZhHXm QQNV6ilkEEPVUQqiSuoK+janWExs1dUJrQg0tHrtXFxwekWxWeC4dbSO2BfbGWms3U4h LMWqX3hwzWUnhPyuX8eaHGP7aWNmkZnhUwZb5BSwwj0mDkRUbxx6yv54IQZN3sFTiLHS YC531P0o6s+lEe8tteQY0LoCQBTfA3hz13UgiiTlQS5iFH3hAjItQeVkB6OX4zsvFRvk M2yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=N7aorBTLAjnGI76c6USKvcDHGYgE4F6gFSjK/BvPAQU=; fh=Mbkw6l/uohI/ndO1H3EnJ85nSvjxWGGNRdmvRMJGCtM=; b=iJEqkBwO3cdw2zI7fONCyiedKmm7a2wKpzq5Tjv1FPhZC7rp819kthWoaTviIHVg+D x+RxySydRK4p5pUwWsq8960kd7T8MbBMA2O7uollMxzNNIdYWSbnFTefZpe6RAPXLRTA a08731XkalfMMSKkqD/PFmAD64TYOXcf7R3GnbZ41jiVkK6L0yO3RT+hlINe1kX3na39 l7jDhzwSbnAIGrrb6dYfkzLOpGB+pJoD4PwpjSKhw2oSey1HMcRJS1Q0+FJ9JAaihGMN JoaxArNWDdqdHwecvuqVLdTDN0ZhYpvnbx0kB/kMOWQqlQWdUHXU6+cDKJDgA6FGygmU B6LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id kx8-20020a170902f94800b001c61bd7cee0si3477682plb.211.2023.10.06.04.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 04:58:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CEDFB818B83D; Fri, 6 Oct 2023 04:58:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232137AbjJFL6h (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Fri, 6 Oct 2023 07:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231939AbjJFL6f (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 6 Oct 2023 07:58:35 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63914CA for <linux-kernel@vger.kernel.org>; Fri, 6 Oct 2023 04:58:34 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ore@pengutronix.de>) id 1qojTN-0006LK-O7; Fri, 06 Oct 2023 13:58:25 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <ore@pengutronix.de>) id 1qojTL-00BVN8-M8; Fri, 06 Oct 2023 13:58:23 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from <ore@pengutronix.de>) id 1qojTL-000bVL-1y; Fri, 06 Oct 2023 13:58:23 +0200 From: Oleksij Rempel <o.rempel@pengutronix.de> To: "David S. Miller" <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>, Eric Dumazet <edumazet@google.com>, Florian Fainelli <f.fainelli@gmail.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Vladimir Oltean <olteanv@gmail.com>, Woojung Huh <woojung.huh@microchip.com>, Arun Ramadoss <arun.ramadoss@microchip.com>, "Russell King (Oracle)" <linux@armlinux.org.uk> Cc: Oleksij Rempel <o.rempel@pengutronix.de>, Dan Carpenter <dan.carpenter@linaro.org>, kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Petr Machata <petrm@nvidia.com>, Lukasz Majewski <lukma@denx.de> Subject: [PATCH net-next v1 1/1] net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries() Date: Fri, 6 Oct 2023 13:58:22 +0200 Message-Id: <20231006115822.144152-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 06 Oct 2023 04:58:50 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779007260389209298 X-GMAIL-MSGID: 1779007260389209298 |
Series |
[net-next,v1,1/1] net: dsa: microchip: Fix uninitialized var in ksz9477_acl_move_entries()
|
|
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
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>
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 --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)