mtd: ichxrom: maybe-uninitialized with gcc-4.9

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Feb 12 18:59:02 PST 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=e70dda0868fad0f74c46df21f7f45fec24f29879
Commit:     e70dda0868fad0f74c46df21f7f45fec24f29879
Parent:     6080ef6e7c0a0592cbcca11200d879faf65e27d4
Author:     Arnd Bergmann <arnd at arndb.de>
AuthorDate: Mon Oct 24 17:28:35 2016 +0200
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Wed Feb 8 14:13:05 2017 -0800

    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 at arndb.de>
    Reviewed-by: Marek Vasut <marex at denx.de>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/maps/ichxrom.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index e17d02a..976d42f 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -57,10 +57,12 @@ static void ichxrom_cleanup(struct ichxrom_window *window)
 {
 	struct ichxrom_map_info *map, *scratch;
 	u16 word;
+	int ret;
 
 	/* Disable writes through the rom window */
-	pci_read_config_word(window->pdev, BIOS_CNTL, &word);
-	pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1);
+	ret = pci_read_config_word(window->pdev, BIOS_CNTL, &word);
+	if (!ret)
+		pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1);
 	pci_dev_put(window->pdev);
 
 	/* Free all of the mtd devices */



More information about the linux-mtd-cvs mailing list