mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Bolle <pebolle@tiscali.nl>
To: "Lee, Chun-Yi" <jlee@suse.com>,
	Matthew Garrett <matthew.garrett@nebula.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] acer-wmi: do not use 'devices' uninitialized
Date: Thu, 24 Jan 2013 14:12:58 +0100	[thread overview]
Message-ID: <1359033178.1325.15.camel@x61.thuisdomein> (raw)

Commit f20aaba9819d0801fb1314363f97239da0100bac ("acer-wmi: fix obj is
NULL but dereferenced") introduced a GCC warning:
    drivers/platform/x86/acer-wmi.c: In function ‘acer_wmi_init’:
    drivers/platform/x86/acer-wmi.c:1216:14: warning: ‘devices’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    drivers/platform/x86/acer-wmi.c:1193:6: note: ‘devices’ was declared here

GCC is correct. In WMID_set_capabilities() there are now clearly codepaths
that use 'devices' uninitialized. (WMID_set_capabilities() is apparently
inlined in acer_wmi_init().) Previously that couldn't happen. So rework
the code to use the previous logic, but also make sure 'obj' will not be
dereferenced while NULL.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
---
Compile tested only!

 drivers/platform/x86/acer-wmi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index afed701..0ddac19 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1197,14 +1197,12 @@ static acpi_status WMID_set_capabilities(void)
 		return status;
 
 	obj = (union acpi_object *) out.pointer;
-	if (obj) {
-		if (obj->type == ACPI_TYPE_BUFFER &&
+	if (obj && obj->type == ACPI_TYPE_BUFFER &&
 			(obj->buffer.length == sizeof(u32) ||
 			obj->buffer.length == sizeof(u64))) {
 			devices = *((u32 *) obj->buffer.pointer);
-		} else if (obj->type == ACPI_TYPE_INTEGER) {
+	} else if (obj && obj->type == ACPI_TYPE_INTEGER) {
 			devices = (u32) obj->integer.value;
-		}
 	} else {
 		kfree(out.pointer);
 		return AE_ERROR;
-- 
1.7.11.7


             reply	other threads:[~2013-01-24 13:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-24 13:12 Paul Bolle [this message]
2013-02-19  2:38 ` joeyli
2013-02-19  8:07   ` Paul Bolle
2013-02-19 15:09     ` joeyli

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=1359033178.1325.15.camel@x61.thuisdomein \
    --to=pebolle@tiscali.nl \
    --cc=jlee@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®