[PATCH] ALSA: ctxfi: Avoid writing uninitialized variable in uaa_to_xfi()

Yizhuo Zhai yzhai003 at ucr.edu
Mon Apr 19 18:41:33 CEST 2021


Inside the function uaa_to_xfi(), variable "l_timer" could be
uninitialized if pci_bus_read_config_dword() returns
PCIBIOS_BAD_REGISTER_NUMBER. However, it is write back to PCI
config space via pci_write_config_dword(), which is potentially
unsafe.

Signed-off-by: Yizhuo <yzhai003 at ucr.edu>
---
 sound/pci/ctxfi/cthw20k1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index 0cea4982ed7d..7c3436499974 100644
--- a/sound/pci/ctxfi/cthw20k1.c
+++ b/sound/pci/ctxfi/cthw20k1.c
@@ -1789,7 +1789,7 @@ static struct capabilities hw_capabilities(struct hw
*hw)
 static int uaa_to_xfi(struct pci_dev *pci)
 {
        unsigned int bar0, bar1, bar2, bar3, bar4, bar5;
-       unsigned int cmd, irq, cl_size, l_timer, pwr;
+       unsigned int cmd, irq, cl_size, l_timer = ~0, pwr;
        unsigned int is_uaa;
        unsigned int data[4] = {0};
        unsigned int io_base;
-- 
2.31.1

-- 
Kind Regards,

*Yizhuo Zhai*

*Computer Science, Graduate Student*
*University of California, Riverside *


More information about the Alsa-devel mailing list