[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 kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux