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-next>] [day] [month] [year] [list]
Message-Id: <20250411115048.34948-1-purvayeshi550@gmail.com>
Date: Fri, 11 Apr 2025 17:20:48 +0530
From: Purva Yeshi <purvayeshi550@...il.com>
To: gregkh@...uxfoundation.org,
	jirislaby@...nel.org
Cc: andriy.shevchenko@...ux.intel.com,
	arnd@...nel.org,
	cang1@...e.co.uk,
	bhelgaas@...gle.com,
	linux-kernel@...r.kernel.org,
	linux-serial@...r.kernel.org,
	Purva Yeshi <purvayeshi550@...il.com>
Subject: [PATCH] tty: serial: 8250: Fix uninitialized variable warnings in pci_oxsemi_tornado_get_divisor

Fix Smatch-detected issue:

drivers/tty/serial/8250/8250_pci.c:1233 pci_oxsemi_tornado_get_divisor()
error: uninitialized symbol 'tcr'.
drivers/tty/serial/8250/8250_pci.c:1234 pci_oxsemi_tornado_get_divisor()
error: uninitialized symbol 'quot'.
drivers/tty/serial/8250/8250_pci.c:1238 pci_oxsemi_tornado_get_divisor()
error: uninitialized symbol 'quot'.
drivers/tty/serial/8250/8250_pci.c:1242 pci_oxsemi_tornado_get_divisor()
error: uninitialized symbol 'cpr'.
drivers/tty/serial/8250/8250_pci.c:1252 pci_oxsemi_tornado_get_divisor()
error: uninitialized symbol 'cpr'.

Fix uninitialized variable usage in pci_oxsemi_tornado_get_divisor() that
was triggering sparse warnings and potential undefined behavior. The
variables tcr, cpr, and quot were used before being explicitly assigned
values, leading to smatch warning in multiple lines of the function.

Initialize quot to 1, tcr to 16, and cpr to OXSEMI_TORNADO_CPR_DEF at the
point of declaration. This ensures safe fallback values are used when these
variables are not conditionally set later in the function, avoiding
uninitialized access.

Signed-off-by: Purva Yeshi <purvayeshi550@...il.com>
---
 drivers/tty/serial/8250/8250_pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 73c200127b08..ba4dedccc29e 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -1187,9 +1187,9 @@ static unsigned int pci_oxsemi_tornado_get_divisor(struct uart_port *port,
 	unsigned int sdiv = DIV_ROUND_CLOSEST(sclk, baud);
 	unsigned int best_squot;
 	unsigned int squot;
-	unsigned int quot;
-	u16 cpr;
-	u8 tcr;
+	unsigned int quot = 1;
+	u16 cpr = OXSEMI_TORNADO_CPR_DEF;  /* Default Control Prescaler Register */
+	u8 tcr = 16;  /* Typical default value for the Timer Control Register */
 	int i;
 
 	/* Old custom speed handling.  */
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ