* [patch 1/2] ACPI, extlog: shift wrapping bug in extlog_get_dsm()
@ 2013-11-05 20:18 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2013-11-05 20:18 UTC (permalink / raw)
To: Len Brown, Chen, Gong; +Cc: Rafael J. Wysocki, linux-acpi, kernel-janitors
obj->buffer.pointer is a u8 pointer so we need to cast it to u64 for the
64 bit shift. Otherwise the upper bits are always zero.
I tweaked a couple nearby lines as well to avoid going over the 80
character limit.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index a6869e1..c4d5e59 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -182,11 +182,9 @@ static int extlog_get_dsm(acpi_handle handle, int rev, int func, u64 *ret)
obj = (union acpi_object *)buf.pointer;
if (obj->type == ACPI_TYPE_INTEGER) {
*ret = obj->integer.value;
- } else if (obj->type == ACPI_TYPE_BUFFER) {
- if (obj->buffer.length <= 8) {
- for (i = 0; i < obj->buffer.length; i++)
- *ret |= (obj->buffer.pointer[i] << (i * 8));
- }
+ } else if (obj->type == ACPI_TYPE_BUFFER && obj->buffer.length <= 8) {
+ for (i = 0; i < obj->buffer.length; i++)
+ *ret |= ((u64)obj->buffer.pointer[i] << (i * 8));
}
kfree(buf.pointer);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-11-05 20:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-05 20:18 [patch 1/2] ACPI, extlog: shift wrapping bug in extlog_get_dsm() Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).