Re: [PATCH] ACPI: EC: clean up tmp variable before reuse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2008-11-01 at 02:42 +0800, Alexey Starikovskiy wrote:
> Fix breakage introduced by following patch
> 27663c5855b10af9ec67bc7dfba001426ba21222 is first bad commit
> commit 27663c5855b10af9ec67bc7dfba001426ba21222
> Author: Matthew Wilcox <willy@xxxxxxxxxxxxxxx>
> Date:   Fri Oct 10 02:22:59 2008 -0400
> 
> acpi_evaluate_integer() does not clear passed variable if
> there is an error at evaluation.
> So if we ignore error, we must supply initialized variable.
> 
> References: http://bugzilla.kernel.org/show_bug.cgi?id=11917
> 	    http://bugzilla.kernel.org/show_bug.cgi?id=11896
The patch from Alexey can fix the problem in bug 11917. 
But the better solution is that the EC global lock should be initialized
based on the return value of _GLK.
    If AE_OK is returned by the acpi_evaluate_integer, the EC global
lock will be assigned based on the return value of _GLK object. If it is
not zero, it indicates that global lock will be used when EC is
accessed. Otherwise it means that global lock won't be used when EC is
accessed.

How about the following patch?

Subject: ACPI: Initialize EC global lock based on the return value of
_GLK
From: Zhao Yakui <yakui.zhao@xxxxxxxxx>

Initialize the EC global lock based on the return value of _GLK object.
Only when AE_OK is returned by the acpi_evaluate_integer, the EC global
lock will be assigned based on the return value of _GLK object.
If the return value is not zero, it means that GLobal lock will be used
when EC is accessed.Otherwise it means that global lock won't be used
when EC is accessed.

Signed-off-by: Zhao Yakui <yakui.zhao@xxxxxxxxx>
cc: Alexey Starikovskiy <astarikovskiy@xxxxxxx>
---
 drivers/acpi/ec.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Index: linux-2.6/drivers/acpi/ec.c
===================================================================
--- linux-2.6.orig/drivers/acpi/ec.c
+++ linux-2.6/drivers/acpi/ec.c
@@ -751,8 +751,19 @@ ec_parse_device(acpi_handle handle, u32 
 		return status;
 	ec->gpe = tmp;
 	/* Use the global lock for all EC transactions? */
-	acpi_evaluate_integer(handle, "_GLK", NULL, &tmp);
-	ec->global_lock = tmp;
+	status = acpi_evaluate_integer(handle, "_GLK", NULL, &tmp);
+	/*
+	 * Only when AE_OK is returned by acpi_evaluate_interger,
+	 * the ec->global_lock will be assigned based on the returned
+	 * value by _GLK.
+	 * If the return value is not zero, it means that Global lock will be
+	 * used when EC is accessed.
+	 * Otherwise the global lock won't be used when EC is accessed.
+	 */
+	if (ACPI_SUCCESS(status))
+		ec->global_lock = !!tmp;
+	 else
+		ec->global_lock = FALSE;
 	ec->handle = handle;
 	return AE_CTRL_TERMINATE;
 }




--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux