[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2025041110-simmering-bogus-7a1d@gregkh>
Date: Fri, 11 Apr 2025 14:29:27 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Purva Yeshi <purvayeshi550@...il.com>
Cc: jirislaby@...nel.org, 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
Subject: Re: [PATCH] tty: serial: 8250: Fix uninitialized variable warnings
in pci_oxsemi_tornado_get_divisor
On Fri, Apr 11, 2025 at 05:20:48PM +0530, Purva Yeshi wrote:
> 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.
Are you really sure? If you follow through the logic, it looks fine to
me. What am I missing? And why doesn't gcc or clang catch this?
> 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.
Where did these magic values come from?
thanks,
greg k-h
Powered by blists - more mailing lists