Commit 51b190b3 authored by Peter Chubb's avatar Peter Chubb Committed by Linus Torvalds

[PATCH] `unaligned access' in acpi get_root_bridge_busnr()

In drivers/acpi/glue.c the address of an integer is cast to the address of
an unsigned long.  This breaks on systems where a long is larger than an
int --- for a start the int can be misaligned; for a second the assignment
through the pointer will overwrite part of the next variable.
Signed-off-by: default avatarPeter Chubb <peterc@gelato.unsw.edu.au>
Acked-by: default avatar"Brown, Len" <len.brown@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 11909d64
...@@ -96,7 +96,7 @@ struct acpi_find_pci_root { ...@@ -96,7 +96,7 @@ struct acpi_find_pci_root {
static acpi_status static acpi_status
do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
{ {
int *busnr = (int *)data; unsigned long *busnr = (unsigned long *)data;
struct acpi_resource_address64 address; struct acpi_resource_address64 address;
if (resource->id != ACPI_RSTYPE_ADDRESS16 && if (resource->id != ACPI_RSTYPE_ADDRESS16 &&
...@@ -115,13 +115,13 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) ...@@ -115,13 +115,13 @@ do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
static int get_root_bridge_busnr(acpi_handle handle) static int get_root_bridge_busnr(acpi_handle handle)
{ {
acpi_status status; acpi_status status;
int bus, bbn; unsigned long bus, bbn;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL,
(unsigned long *)&bbn); &bbn);
if (status == AE_NOT_FOUND) { if (status == AE_NOT_FOUND) {
/* Assume bus = 0 */ /* Assume bus = 0 */
printk(KERN_INFO PREFIX printk(KERN_INFO PREFIX
...@@ -153,7 +153,7 @@ static int get_root_bridge_busnr(acpi_handle handle) ...@@ -153,7 +153,7 @@ static int get_root_bridge_busnr(acpi_handle handle)
} }
exit: exit:
acpi_os_free(buffer.pointer); acpi_os_free(buffer.pointer);
return bbn; return (int)bbn;
} }
static acpi_status static acpi_status
......
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