Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941357AbcJXUtA (ORCPT ); Mon, 24 Oct 2016 16:49:00 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35567 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938760AbcJXUsz (ORCPT ); Mon, 24 Oct 2016 16:48:55 -0400 Subject: Re: [PATCH] mtd: ichxrom: maybe-uninitialized with gcc-4.9 To: Arnd Bergmann , David Woodhouse , Brian Norris References: <20161024152853.2673518-1-arnd@arndb.de> Cc: Julia Lawall , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org From: Marek Vasut Message-ID: <470c5483-949c-6e2a-cd52-73d99748b312@gmail.com> Date: Mon, 24 Oct 2016 22:47:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161024152853.2673518-1-arnd@arndb.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1582 Lines: 46 On 10/24/2016 05:28 PM, Arnd Bergmann wrote: > 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 Reviewed-by: Marek Vasut > --- > 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 e17d02ae03f0..976d42f63aef 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 */ > -- Best regards, Marek Vasut