[patch 1/2] ACPI, extlog: shift wrapping bug in extlog_get_dsm()

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

 



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@xxxxxxxxxx>

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