Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1733065 > unrolled thread

[PATCH] acpi: watchdog: properly initialize resources

Started byArnd Bergmann <arnd@arndb.de>
First post2017-09-15 22:00 +0200
Last post2017-09-19 02:00 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] acpi: watchdog: properly initialize resources Arnd Bergmann <arnd@arndb.de> - 2017-09-15 22:00 +0200
    Re: [PATCH] acpi: watchdog: properly initialize resources Guenter Roeck <linux@roeck-us.net> - 2017-09-16 00:40 +0200
    Re: [PATCH] acpi: watchdog: properly initialize resources Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-09-16 09:00 +0200
      Re: [PATCH] acpi: watchdog: properly initialize resources "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-09-19 02:00 +0200

#1733065 — [PATCH] acpi: watchdog: properly initialize resources

FromArnd Bergmann <arnd@arndb.de>
Date2017-09-15 22:00 +0200
Subject[PATCH] acpi: watchdog: properly initialize resources
Message-ID<uq4Wm-7vc-9@gated-at.bofh.it>
We copy a local resource structure into a list, but only
initialize some of its members, as pointed out by gcc-4.4:

drivers/acpi/acpi_watchdog.c: In function 'acpi_watchdog_init':
drivers/acpi/acpi_watchdog.c:105: error: 'res.child' may be used uninitialized in this function
drivers/acpi/acpi_watchdog.c:105: error: 'res.sibling' may be used uninitialized in this function
drivers/acpi/acpi_watchdog.c:105: error: 'res.parent' may be used uninitialized in this function
drivers/acpi/acpi_watchdog.c:105: error: 'res.desc' may be used uninitialized in this function
drivers/acpi/acpi_watchdog.c:105: error: 'res.name' may be used uninitialized in this function

Newer compilers can presumably optimize the uninitialized access
away entirely and don't warn at all, but rely on the kzalloc()
to zero the structure first. This adds an explicit initialization
to force consistent behavior.

Fixes: 058dfc767008 ("ACPI / watchdog: Add support for WDAT hardware watchdog")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/acpi/acpi_watchdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
index bf22c29d2517..11b113f8e367 100644
--- a/drivers/acpi/acpi_watchdog.c
+++ b/drivers/acpi/acpi_watchdog.c
@@ -66,7 +66,7 @@ void __init acpi_watchdog_init(void)
 	for (i = 0; i < wdat->entries; i++) {
 		const struct acpi_generic_address *gas;
 		struct resource_entry *rentry;
-		struct resource res;
+		struct resource res = {};
 		bool found;
 
 		gas = &entries[i].register_region;
-- 
2.9.0

[toc] | [next] | [standalone]


#1733126

FromGuenter Roeck <linux@roeck-us.net>
Date2017-09-16 00:40 +0200
Message-ID<uq7rb-OY-13@gated-at.bofh.it>
In reply to#1733065
On Fri, Sep 15, 2017 at 09:55:18PM +0200, Arnd Bergmann wrote:
> We copy a local resource structure into a list, but only
> initialize some of its members, as pointed out by gcc-4.4:
> 
> drivers/acpi/acpi_watchdog.c: In function 'acpi_watchdog_init':
> drivers/acpi/acpi_watchdog.c:105: error: 'res.child' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.sibling' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.parent' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.desc' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.name' may be used uninitialized in this function
> 
> Newer compilers can presumably optimize the uninitialized access
> away entirely and don't warn at all, but rely on the kzalloc()
> to zero the structure first. This adds an explicit initialization
> to force consistent behavior.
> 
> Fixes: 058dfc767008 ("ACPI / watchdog: Add support for WDAT hardware watchdog")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/acpi/acpi_watchdog.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c
> index bf22c29d2517..11b113f8e367 100644
> --- a/drivers/acpi/acpi_watchdog.c
> +++ b/drivers/acpi/acpi_watchdog.c
> @@ -66,7 +66,7 @@ void __init acpi_watchdog_init(void)
>  	for (i = 0; i < wdat->entries; i++) {
>  		const struct acpi_generic_address *gas;
>  		struct resource_entry *rentry;
> -		struct resource res;
> +		struct resource res = {};
>  		bool found;
>  
>  		gas = &entries[i].register_region;
> -- 
> 2.9.0
> 

[toc] | [prev] | [next] | [standalone]


#1733219

FromMika Westerberg <mika.westerberg@linux.intel.com>
Date2017-09-16 09:00 +0200
Message-ID<uqff4-6i3-5@gated-at.bofh.it>
In reply to#1733065
On Fri, Sep 15, 2017 at 09:55:18PM +0200, Arnd Bergmann wrote:
> We copy a local resource structure into a list, but only
> initialize some of its members, as pointed out by gcc-4.4:
> 
> drivers/acpi/acpi_watchdog.c: In function 'acpi_watchdog_init':
> drivers/acpi/acpi_watchdog.c:105: error: 'res.child' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.sibling' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.parent' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.desc' may be used uninitialized in this function
> drivers/acpi/acpi_watchdog.c:105: error: 'res.name' may be used uninitialized in this function
> 
> Newer compilers can presumably optimize the uninitialized access
> away entirely and don't warn at all, but rely on the kzalloc()
> to zero the structure first. This adds an explicit initialization
> to force consistent behavior.
> 
> Fixes: 058dfc767008 ("ACPI / watchdog: Add support for WDAT hardware watchdog")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

[toc] | [prev] | [next] | [standalone]


#1734548

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2017-09-19 02:00 +0200
Message-ID<ure7g-4Xi-7@gated-at.bofh.it>
In reply to#1733219
On Saturday, September 16, 2017 8:56:49 AM CEST Mika Westerberg wrote:
> On Fri, Sep 15, 2017 at 09:55:18PM +0200, Arnd Bergmann wrote:
> > We copy a local resource structure into a list, but only
> > initialize some of its members, as pointed out by gcc-4.4:
> > 
> > drivers/acpi/acpi_watchdog.c: In function 'acpi_watchdog_init':
> > drivers/acpi/acpi_watchdog.c:105: error: 'res.child' may be used uninitialized in this function
> > drivers/acpi/acpi_watchdog.c:105: error: 'res.sibling' may be used uninitialized in this function
> > drivers/acpi/acpi_watchdog.c:105: error: 'res.parent' may be used uninitialized in this function
> > drivers/acpi/acpi_watchdog.c:105: error: 'res.desc' may be used uninitialized in this function
> > drivers/acpi/acpi_watchdog.c:105: error: 'res.name' may be used uninitialized in this function
> > 
> > Newer compilers can presumably optimize the uninitialized access
> > away entirely and don't warn at all, but rely on the kzalloc()
> > to zero the structure first. This adds an explicit initialization
> > to force consistent behavior.
> > 
> > Fixes: 058dfc767008 ("ACPI / watchdog: Add support for WDAT hardware watchdog")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Applied, thanks!

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web