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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221210220601.77648-2-andriy.shevchenko@linux.intel.com>
Date:   Sun, 11 Dec 2022 00:05:59 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        Haibo Chen <haibo.chen@....com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 2/4] gpio: pca953x: avoid logically dead code

From: Haibo Chen <haibo.chen@....com>

The current code logic make the condition "else if (reg >= 0x54)"
can't be true, cause the dead code. So fix it to match the coder
expectation. This is reported by Coverity.

Fixes: 13c5d4ce8060 ("gpio: pca953x: Add support for PCAL6534")
Signed-off-by: Haibo Chen <haibo.chen@....com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
v2: shuffled code to check bigger value first (Andy)
 drivers/gpio/gpio-pca953x.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 5299e5bb76d6..2c8586b3191f 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -309,26 +309,26 @@ static bool pcal6534_check_register(struct pca953x_chip *chip, unsigned int reg,
 	int bank;
 	int offset;
 
-	if (reg >= 0x30) {
+	if (reg >= 0x54) {
 		/*
-		 * Reserved block between 14h and 2Fh does not align on
-		 * expected bank boundaries like other devices.
+		 * Handle lack of reserved registers after output port
+		 * configuration register to form a bank.
 		 */
-		int temp = reg - 0x30;
+		int temp = reg - 0x54;
 
 		bank = temp / NBANK(chip);
 		offset = temp - (bank * NBANK(chip));
-		bank += 8;
-	} else if (reg >= 0x54) {
+		bank += 16;
+	} else if (reg >= 0x30) {
 		/*
-		 * Handle lack of reserved registers after output port
-		 * configuration register to form a bank.
+		 * Reserved block between 14h and 2Fh does not align on
+		 * expected bank boundaries like other devices.
 		 */
-		int temp = reg - 0x54;
+		int temp = reg - 0x30;
 
 		bank = temp / NBANK(chip);
 		offset = temp - (bank * NBANK(chip));
-		bank += 16;
+		bank += 8;
 	} else {
 		bank = reg / NBANK(chip);
 		offset = reg - (bank * NBANK(chip));
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ