lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220902084521.3466638-1-casper.casan@gmail.com>
Date:   Fri,  2 Sep 2022 10:45:21 +0200
From:   Casper Andersson <casper.casan@...il.com>
To:     "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>
Cc:     Casper Andersson <casper.casan@...il.com>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Steen Hegelund <Steen.Hegelund@...rochip.com>,
        UNGLinuxDriver@...rochip.com, netdev@...r.kernel.org,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: [PATCH net-next] net: sparx5: fix return values to correctly use bool

Function was declared to return bool, but used error return strategy (0
for success, else error). Now correctly uses bool to indicate whether
the entry was found or not.

Does not have any impact on functionality.

Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: Casper Andersson <casper.casan@...il.com>
---
 .../ethernet/microchip/sparx5/sparx5_mactable.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c b/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c
index a5837dbe0c7e..4bc80bc7475f 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c
@@ -189,7 +189,8 @@ bool sparx5_mact_getnext(struct sparx5 *sparx5,
 bool sparx5_mact_find(struct sparx5 *sparx5,
 		      const unsigned char mac[ETH_ALEN], u16 vid, u32 *pcfg2)
 {
-	int ret;
+	bool found = false;
+	int err;
 	u32 cfg2;
 
 	mutex_lock(&sparx5->lock);
@@ -201,18 +202,18 @@ bool sparx5_mact_find(struct sparx5 *sparx5,
 		LRN_COMMON_ACCESS_CTRL_MAC_TABLE_ACCESS_SHOT_SET(1),
 		sparx5, LRN_COMMON_ACCESS_CTRL);
 
-	ret = sparx5_mact_wait_for_completion(sparx5);
-	if (ret == 0) {
+	err = sparx5_mact_wait_for_completion(sparx5);
+	if (!err) {
 		cfg2 = spx5_rd(sparx5, LRN_MAC_ACCESS_CFG_2);
-		if (LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_VLD_GET(cfg2))
+		if (LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_VLD_GET(cfg2)) {
 			*pcfg2 = cfg2;
-		else
-			ret = -ENOENT;
+			found = true;
+		}
 	}
 
 	mutex_unlock(&sparx5->lock);
 
-	return ret;
+	return found;
 }
 
 int sparx5_mact_forget(struct sparx5 *sparx5,
@@ -296,7 +297,7 @@ int sparx5_add_mact_entry(struct sparx5 *sparx5,
 	u32 cfg2;
 
 	ret = sparx5_mact_find(sparx5, addr, vid, &cfg2);
-	if (!ret)
+	if (ret)
 		return 0;
 
 	/* In case the entry already exists, don't add it again to SW,
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ