All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: ichxrom: maybe-uninitialized with gcc-4.9
@ 2016-10-24 15:28 Arnd Bergmann
  2016-10-24 20:47 ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2016-10-24 15:28 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris
  Cc: Arnd Bergmann, Julia Lawall, linux-mtd, linux-kernel

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>
---
 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 */
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: ichxrom: maybe-uninitialized with gcc-4.9
  2016-10-24 15:28 [PATCH] mtd: ichxrom: maybe-uninitialized with gcc-4.9 Arnd Bergmann
@ 2016-10-24 20:47 ` Marek Vasut
  2017-02-08 22:17   ` Brian Norris
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2016-10-24 20:47 UTC (permalink / raw)
  To: Arnd Bergmann, David Woodhouse, Brian Norris
  Cc: Julia Lawall, linux-mtd, linux-kernel

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 <arnd@arndb.de>

Reviewed-by: Marek Vasut <marex@denx.de>

> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: ichxrom: maybe-uninitialized with gcc-4.9
  2016-10-24 20:47 ` Marek Vasut
@ 2017-02-08 22:17   ` Brian Norris
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Norris @ 2017-02-08 22:17 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Arnd Bergmann, David Woodhouse, Julia Lawall, linux-mtd,
	linux-kernel

On Mon, Oct 24, 2016 at 10:47:59PM +0200, Marek Vasut wrote:
> 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 <arnd@arndb.de>
> 
> Reviewed-by: Marek Vasut <marex@denx.de>

Applied to l2-mtd.git

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-08 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-24 15:28 [PATCH] mtd: ichxrom: maybe-uninitialized with gcc-4.9 Arnd Bergmann
2016-10-24 20:47 ` Marek Vasut
2017-02-08 22:17   ` Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.