diff mbox series

piix: Fix uninitialized use in piix_check_450nx()

Message ID CABvMjLSff9jZe4D-vOHrwn4gsgoFEShuJo6qjq9n3cBEjnn5yA@mail.gmail.com
State New
Headers show
Series piix: Fix uninitialized use in piix_check_450nx() | expand

Commit Message

Yizhuo Zhai April 19, 2021, 4:43 p.m. UTC
Inside the function piix_check_450nx(), variable "cfg" could be
uninitialized if pci_bus_read_config_word() returns
PCIBIOS_BAD_REGISTER_NUMBER. However, it is directly used in the
if statement, which is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/ide/piix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

        {
                /* Look for 450NX PXB. Check for problem configurations
diff mbox series

Patch

diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
index a671cead6ae7..e01266c6cbbc 100644
--- a/drivers/ide/piix.c
+++ b/drivers/ide/piix.c
@@ -397,7 +397,7 @@  static int piix_init_one(struct pci_dev *dev,
const struct pci_device_id *id)
 static void piix_check_450nx(void)
 {
        struct pci_dev *pdev = NULL;
-       u16 cfg;
+       u16 cfg = ~0;
        while((pdev=pci_get_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82454NX, pdev))!=NULL)