From: Greg KH <gregkh@linuxfoundation.org>
To: Purva Yeshi <purvayeshi550@gmail.com>
Cc: jirislaby@kernel.org, andriy.shevchenko@linux.intel.com,
arnd@kernel.org, cang1@live.co.uk, bhelgaas@google.com,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: serial: 8250: Fix uninitialized variable warnings in pci_oxsemi_tornado_get_divisor
Date: Fri, 11 Apr 2025 14:29:27 +0200 [thread overview]
Message-ID: <2025041110-simmering-bogus-7a1d@gregkh> (raw)
In-Reply-To: <20250411115048.34948-1-purvayeshi550@gmail.com>
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
prev parent reply other threads:[~2025-04-11 12:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 11:50 [PATCH] tty: serial: 8250: Fix uninitialized variable warnings in pci_oxsemi_tornado_get_divisor Purva Yeshi
2025-04-11 12:29 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025041110-simmering-bogus-7a1d@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@kernel.org \
--cc=bhelgaas@google.com \
--cc=cang1@live.co.uk \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=purvayeshi550@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox