PCI_READ_VIA_DWORD_OP: Fix *val uninitialized bug
authorShinya Kuribayashi <shinya.kuribayashi@necel.com>
Fri, 17 Aug 2007 03:43:44 +0000 (12:43 +0900)
committerWolfgang Denk <wd@denx.de>
Sat, 18 Aug 2007 19:38:45 +0000 (21:38 +0200)
This patch has been sent on:
- 6 Jun 2007

Many users of PCI config read routines tend to ignore the function
ret value, and are only concerned about the contents of *val. Based
on this, pci_hose_read_config_{byte,word}_via_dword should initialize
the *val on dword read error.

Without this fix, for example, we'll go on scanning bus with vendor or
header_type uninitialized. This brings many unnecessary config trials.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
drivers/pci.c

index 41589192c1c835669eaa98437840e9a6f97063ea..50ca6b0bad67a2345992799f5bd24db101e147a6 100644 (file)
@@ -82,8 +82,10 @@ int pci_hose_read_config_##size##_via_dword(struct pci_controller *hose,\
 {                                                                      \
        u32 val32;                                                      \
                                                                        \
-       if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0)\
+       if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0) { \
+               *val = -1;                                              \
                return -1;                                              \
+       }                                                               \
                                                                        \
        *val = (val32 >> ((offset & (int)off_mask) * 8));               \
                                                                        \