mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 01:04:19 +08:00
x86/PCI: fix boundary checking when using root CRS
Don't touch info->res_num if we are out of space. Acked-by: Gary Hade <garyhade@us.ibm.com> Tested-by: Gary Hade <garyhade@us.ibm.com> Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
12abb8ba84
commit
2cdb3f1d83
@ -68,6 +68,10 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct resource *root;
|
struct resource *root;
|
||||||
int max_root_bus_resources = PCI_BUS_NUM_RESOURCES;
|
int max_root_bus_resources = PCI_BUS_NUM_RESOURCES;
|
||||||
|
u64 start, end;
|
||||||
|
|
||||||
|
if (bus_has_transparent_bridge(info->bus))
|
||||||
|
max_root_bus_resources -= 3;
|
||||||
|
|
||||||
status = resource_to_addr(acpi_res, &addr);
|
status = resource_to_addr(acpi_res, &addr);
|
||||||
if (!ACPI_SUCCESS(status))
|
if (!ACPI_SUCCESS(status))
|
||||||
@ -84,25 +88,24 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
|
|||||||
} else
|
} else
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
|
|
||||||
res = &info->res[info->res_num];
|
start = addr.minimum + addr.translation_offset;
|
||||||
res->name = info->name;
|
end = start + addr.address_length - 1;
|
||||||
res->flags = flags;
|
|
||||||
res->start = addr.minimum + addr.translation_offset;
|
|
||||||
res->end = res->start + addr.address_length - 1;
|
|
||||||
res->child = NULL;
|
|
||||||
|
|
||||||
if (bus_has_transparent_bridge(info->bus))
|
|
||||||
max_root_bus_resources -= 3;
|
|
||||||
if (info->res_num >= max_root_bus_resources) {
|
if (info->res_num >= max_root_bus_resources) {
|
||||||
printk(KERN_WARNING "PCI: Failed to allocate 0x%lx-0x%lx "
|
printk(KERN_WARNING "PCI: Failed to allocate 0x%lx-0x%lx "
|
||||||
"from %s for %s due to _CRS returning more than "
|
"from %s for %s due to _CRS returning more than "
|
||||||
"%d resource descriptors\n", (unsigned long) res->start,
|
"%d resource descriptors\n", (unsigned long) start,
|
||||||
(unsigned long) res->end, root->name, info->name,
|
(unsigned long) end, root->name, info->name,
|
||||||
max_root_bus_resources);
|
max_root_bus_resources);
|
||||||
info->res_num++;
|
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res = &info->res[info->res_num];
|
||||||
|
res->name = info->name;
|
||||||
|
res->flags = flags;
|
||||||
|
res->start = start;
|
||||||
|
res->end = end;
|
||||||
|
res->child = NULL;
|
||||||
|
|
||||||
if (insert_resource(root, res)) {
|
if (insert_resource(root, res)) {
|
||||||
printk(KERN_ERR "PCI: Failed to allocate 0x%lx-0x%lx "
|
printk(KERN_ERR "PCI: Failed to allocate 0x%lx-0x%lx "
|
||||||
"from %s for %s\n", (unsigned long) res->start,
|
"from %s for %s\n", (unsigned long) res->start,
|
||||||
|
Loading…
Reference in New Issue
Block a user