Re: [PATCH] serial: 8250_pci: Fix uninitialized variable use in pci_oxsemi_tornado_get_divisor

From: Greg Kroah-Hartman

Date: Wed Jan 21 2026 - 11:37:02 EST


On Thu, Jan 22, 2026 at 12:53:52AM +0900, Lee Yongjun wrote:
> Smatch reports the following errors:
>
> drivers/tty/serial/8250/8250_pci.c:1246 pci_oxsemi_tornado_get_divisor() error: uninitialized symbol 'tcr'.
> drivers/tty/serial/8250/8250_pci.c:1247 pci_oxsemi_tornado_get_divisor() error: uninitialized symbol 'quot'.
> drivers/tty/serial/8250/8250_pci.c:1251 pci_oxsemi_tornado_get_divisor() error: uninitialized symbol 'quot'.
> drivers/tty/serial/8250/8250_pci.c:1255 pci_oxsemi_tornado_get_divisor() error: uninitialized symbol 'cpr'.
> drivers/tty/serial/8250/8250_pci.c:1265 pci_oxsemi_tornado_get_divisor() error: uninitialized symbol 'cpr'.
>
> These variables are initialized in the if branch or inside the loop in
> the else branch. However, if the loop finishes without finding a suitable
> divisor, they remain uninitialized.

But can that ever really happen? Please step through it all with the
values that the hardware provides to see this.

> Initialize 'quot', 'cpr', and 'tcr' to 0 to prevent undefined behavior.

Why haven't we seen any real problems with this? I think this is ok
as-is. Maybe a little bit complex and non-intutive, but ok.

thanks,

greg k-h