Commit dda0273d authored by Andy Grover's avatar Andy Grover

Last little bit of C99 init fixes

Fix panic in EC driver (Dom B)
Add a some more sanity checking (Richard Schaal)
parent 4916e118
/* /*
* acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 35 $) * acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 38 $)
* *
* Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
* Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
...@@ -62,14 +62,14 @@ static int acpi_ec_start (struct acpi_device *device); ...@@ -62,14 +62,14 @@ static int acpi_ec_start (struct acpi_device *device);
static int acpi_ec_stop (struct acpi_device *device, int type); static int acpi_ec_stop (struct acpi_device *device, int type);
static struct acpi_driver acpi_ec_driver = { static struct acpi_driver acpi_ec_driver = {
name: ACPI_EC_DRIVER_NAME, .name = ACPI_EC_DRIVER_NAME,
class: ACPI_EC_CLASS, .class = ACPI_EC_CLASS,
ids: ACPI_EC_HID, .ids = ACPI_EC_HID,
ops: { .ops = {
add: acpi_ec_add, .add = acpi_ec_add,
remove: acpi_ec_remove, .remove = acpi_ec_remove,
start: acpi_ec_start, .start = acpi_ec_start,
stop: acpi_ec_stop, .stop = acpi_ec_stop,
}, },
}; };
...@@ -134,7 +134,7 @@ static int ...@@ -134,7 +134,7 @@ static int
acpi_ec_read ( acpi_ec_read (
struct acpi_ec *ec, struct acpi_ec *ec,
u8 address, u8 address,
u8 *data) u32 *data)
{ {
acpi_status status = AE_OK; acpi_status status = AE_OK;
int result = 0; int result = 0;
...@@ -167,7 +167,7 @@ acpi_ec_read ( ...@@ -167,7 +167,7 @@ acpi_ec_read (
goto end; goto end;
acpi_hw_low_level_read(8, (u32*) data, &ec->data_addr, 0); acpi_hw_low_level_read(8, data, &ec->data_addr, 0);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
*data, address)); *data, address));
...@@ -237,7 +237,7 @@ acpi_ec_write ( ...@@ -237,7 +237,7 @@ acpi_ec_write (
static int static int
acpi_ec_query ( acpi_ec_query (
struct acpi_ec *ec, struct acpi_ec *ec,
u8 *data) u32 *data)
{ {
int result = 0; int result = 0;
acpi_status status = AE_OK; acpi_status status = AE_OK;
...@@ -269,7 +269,7 @@ acpi_ec_query ( ...@@ -269,7 +269,7 @@ acpi_ec_query (
if (result) if (result)
goto end; goto end;
acpi_hw_low_level_read(8, (u32*) data, &ec->data_addr, 0); acpi_hw_low_level_read(8, data, &ec->data_addr, 0);
if (!*data) if (!*data)
result = -ENODATA; result = -ENODATA;
...@@ -328,7 +328,7 @@ acpi_ec_gpe_handler ( ...@@ -328,7 +328,7 @@ acpi_ec_gpe_handler (
{ {
acpi_status status = AE_OK; acpi_status status = AE_OK;
struct acpi_ec *ec = (struct acpi_ec *) data; struct acpi_ec *ec = (struct acpi_ec *) data;
u8 value = 0; u32 value = 0;
unsigned long flags = 0; unsigned long flags = 0;
struct acpi_ec_query_data *query_data = NULL; struct acpi_ec_query_data *query_data = NULL;
...@@ -336,7 +336,7 @@ acpi_ec_gpe_handler ( ...@@ -336,7 +336,7 @@ acpi_ec_gpe_handler (
return; return;
spin_lock_irqsave(&ec->lock, flags); spin_lock_irqsave(&ec->lock, flags);
acpi_hw_low_level_read(8, (u32*) &value, &ec->command_addr, 0); acpi_hw_low_level_read(8, &value, &ec->command_addr, 0);
spin_unlock_irqrestore(&ec->lock, flags); spin_unlock_irqrestore(&ec->lock, flags);
/* TBD: Implement asynch events! /* TBD: Implement asynch events!
...@@ -398,6 +398,7 @@ acpi_ec_space_handler ( ...@@ -398,6 +398,7 @@ acpi_ec_space_handler (
{ {
int result = 0; int result = 0;
struct acpi_ec *ec = NULL; struct acpi_ec *ec = NULL;
u32 temp = 0;
ACPI_FUNCTION_TRACE("acpi_ec_space_handler"); ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
...@@ -408,7 +409,8 @@ acpi_ec_space_handler ( ...@@ -408,7 +409,8 @@ acpi_ec_space_handler (
switch (function) { switch (function) {
case ACPI_READ: case ACPI_READ:
result = acpi_ec_read(ec, (u8) address, (u8*) value); result = acpi_ec_read(ec, (u8) address, &temp);
*value = (acpi_integer) temp;
break; break;
case ACPI_WRITE: case ACPI_WRITE:
result = acpi_ec_write(ec, (u8) address, (u8) *value); result = acpi_ec_write(ec, (u8) address, (u8) *value);
......
...@@ -330,6 +330,11 @@ acpi_table_get_sdt ( ...@@ -330,6 +330,11 @@ acpi_table_get_sdt (
return -ENODEV; return -ENODEV;
} }
if (acpi_table_compute_checksum(header, header->length)) {
printk(KERN_WARNING PREFIX "Invalid XSDT checksum\n");
return -ENODEV;
}
sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3; sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
if (sdt.count > ACPI_MAX_TABLES) { if (sdt.count > ACPI_MAX_TABLES) {
printk(KERN_WARNING PREFIX "Truncated %lu XSDT entries\n", printk(KERN_WARNING PREFIX "Truncated %lu XSDT entries\n",
...@@ -370,6 +375,11 @@ acpi_table_get_sdt ( ...@@ -370,6 +375,11 @@ acpi_table_get_sdt (
return -ENODEV; return -ENODEV;
} }
if (acpi_table_compute_checksum(header, header->length)) {
printk(KERN_WARNING PREFIX "Invalid RSDT checksum\n");
return -ENODEV;
}
sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 2; sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 2;
if (sdt.count > ACPI_MAX_TABLES) { if (sdt.count > ACPI_MAX_TABLES) {
printk(KERN_WARNING PREFIX "Truncated %lu RSDT entries\n", printk(KERN_WARNING PREFIX "Truncated %lu RSDT entries\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment