public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Ryan Kennedy <ryan5544@gmail.com>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] acpi: watchdog: properly initialize resources
Date: Fri, 15 Sep 2017 15:39:09 -0700	[thread overview]
Message-ID: <20170915223909.GA3420@roeck-us.net> (raw)
In-Reply-To: <20170915195526.1541309-1-arnd@arndb.de>

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
> 

  reply	other threads:[~2017-09-15 22:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-15 19:55 [PATCH] acpi: watchdog: properly initialize resources Arnd Bergmann
2017-09-15 22:39 ` Guenter Roeck [this message]
2017-09-16  6:56 ` Mika Westerberg
2017-09-18 23:41   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170915223909.GA3420@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=arnd@arndb.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=ryan5544@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox