Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: ichxrom: maybe-uninitialized with gcc-4.9

pci_read_config_word() might fail and not initialize its output,
as pointed out by older versions of gcc when using the -Wmaybe-unintialized
flag:

drivers/mtd/maps/ichxrom.c: In function ‘ichxrom_cleanup’:
drivers/mtd/maps/ichxrom.c:63:2: error: ‘word’ is used uninitialized in this function [-Werror=uninitialized]

This is apparently a correct warning, though it does not show up
with newer compilers. Changing the code to not attempt to write
back uninitialized data into PCI config space is a correct
fix for the problem and avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Marek Vasut <marex@denx.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Arnd Bergmann and committed by
Brian Norris
e70dda08 6080ef6e

+4 -2
+4 -2
drivers/mtd/maps/ichxrom.c
··· 57 57 { 58 58 struct ichxrom_map_info *map, *scratch; 59 59 u16 word; 60 + int ret; 60 61 61 62 /* Disable writes through the rom window */ 62 - pci_read_config_word(window->pdev, BIOS_CNTL, &word); 63 - pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); 63 + ret = pci_read_config_word(window->pdev, BIOS_CNTL, &word); 64 + if (!ret) 65 + pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); 64 66 pci_dev_put(window->pdev); 65 67 66 68 /* Free all of the mtd devices */