public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acer-wmi: do not use 'devices' uninitialized
@ 2013-01-24 13:12 Paul Bolle
  2013-02-19  2:38 ` joeyli
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Bolle @ 2013-01-24 13:12 UTC (permalink / raw)
  To: Lee, Chun-Yi, Matthew Garrett; +Cc: platform-driver-x86, linux-kernel

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


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

* Re: [PATCH] acer-wmi: do not use 'devices' uninitialized
  2013-01-24 13:12 [PATCH] acer-wmi: do not use 'devices' uninitialized Paul Bolle
@ 2013-02-19  2:38 ` joeyli
  2013-02-19  8:07   ` Paul Bolle
  0 siblings, 1 reply; 4+ messages in thread
From: joeyli @ 2013-02-19  2:38 UTC (permalink / raw)
  To: Paul Bolle; +Cc: Matthew Garrett, platform-driver-x86, linux-kernel

Hi Paul, 

Sorry for I am late to reply your patch.

於 四,2013-01-24 於 14:12 +0100,Paul Bolle 提到:
> 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>

Zhang Rui sent similar patch for fix the warning:
http://www.mail-archive.com/platform-driver-x86@vger.kernel.org/msg04016.html


Still appreciate for your contribution!


Thanks a lot!
Joey Lee

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



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

* Re: [PATCH] acer-wmi: do not use 'devices' uninitialized
  2013-02-19  2:38 ` joeyli
@ 2013-02-19  8:07   ` Paul Bolle
  2013-02-19 15:09     ` joeyli
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Bolle @ 2013-02-19  8:07 UTC (permalink / raw)
  To: joeyli; +Cc: Matthew Garrett, platform-driver-x86, linux-kernel, Zhang Rui

Joey.

On Tue, 2013-02-19 at 10:38 +0800, joeyli wrote:
> Zhang Rui sent similar patch for fix the warning:
> http://www.mail-archive.com/platform-driver-x86@vger.kernel.org/msg04016.html

I see. It didn't make it into the v3.8 release. Could someone please
send a note to the stable list once Zhang's patch hits mainline
(presumably in one of the v3.9 release candidates)?


Paul Bolle


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

* Re: [PATCH] acer-wmi: do not use 'devices' uninitialized
  2013-02-19  8:07   ` Paul Bolle
@ 2013-02-19 15:09     ` joeyli
  0 siblings, 0 replies; 4+ messages in thread
From: joeyli @ 2013-02-19 15:09 UTC (permalink / raw)
  To: Paul Bolle; +Cc: Matthew Garrett, platform-driver-x86, linux-kernel, Zhang Rui

於 二,2013-02-19 於 09:07 +0100,Paul Bolle 提到:
> Joey.
> 
> On Tue, 2013-02-19 at 10:38 +0800, joeyli wrote:
> > Zhang Rui sent similar patch for fix the warning:
> > http://www.mail-archive.com/platform-driver-x86@vger.kernel.org/msg04016.html
> 
> I see. It didn't make it into the v3.8 release. Could someone please
> send a note to the stable list once Zhang's patch hits mainline
> (presumably in one of the v3.9 release candidates)?
> 
> 
> Paul Bolle
> 
> .

I will track this patch and send the note to stable kernel when it
merged to platform driver git.


Thanks a lot!
Joey Lee


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

end of thread, other threads:[~2013-02-19 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24 13:12 [PATCH] acer-wmi: do not use 'devices' uninitialized Paul Bolle
2013-02-19  2:38 ` joeyli
2013-02-19  8:07   ` Paul Bolle
2013-02-19 15:09     ` joeyli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox