diff options
author | Yijing Wang <wangyijing@huawei.com> | 2013-06-06 03:34:49 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2013-06-18 12:44:59 -0400 |
commit | 429ac0995e74b24d83ca058e802faed9a562651b (patch) | |
tree | d4ae16058f618dffadc6ace16d727549e77952d6 /arch/ia64/pci/pci.c | |
parent | 5cd7595dea8d54d93124cfc4faec103ce56ab03d (diff) |
PCI/IA64: Allocate pci_root_info instead of using stack
We need to pass around info for release function.
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/ia64/pci/pci.c')
-rw-r--r-- | arch/ia64/pci/pci.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 82eb8b2a4f1d..6da469a38a49 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c | |||
@@ -331,7 +331,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
331 | int domain = root->segment; | 331 | int domain = root->segment; |
332 | int bus = root->secondary.start; | 332 | int bus = root->secondary.start; |
333 | struct pci_controller *controller; | 333 | struct pci_controller *controller; |
334 | struct pci_root_info info; | 334 | struct pci_root_info *info = NULL; |
335 | int busnum = root->secondary.start; | ||
335 | struct pci_bus *pbus; | 336 | struct pci_bus *pbus; |
336 | char *name; | 337 | char *name; |
337 | int pxm; | 338 | int pxm; |
@@ -348,35 +349,43 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
348 | controller->node = pxm_to_node(pxm); | 349 | controller->node = pxm_to_node(pxm); |
349 | #endif | 350 | #endif |
350 | 351 | ||
351 | INIT_LIST_HEAD(&info.resources); | 352 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
353 | if (!info) { | ||
354 | printk(KERN_WARNING | ||
355 | "pci_bus %04x:%02x: ignored (out of memory)\n", | ||
356 | root->segment, busnum); | ||
357 | goto out2; | ||
358 | } | ||
359 | |||
360 | INIT_LIST_HEAD(&info->resources); | ||
352 | /* insert busn resource at first */ | 361 | /* insert busn resource at first */ |
353 | pci_add_resource(&info.resources, &root->secondary); | 362 | pci_add_resource(&info->resources, &root->secondary); |
354 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, | 363 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, |
355 | &info.res_num); | 364 | &info->res_num); |
356 | if (info.res_num) { | 365 | if (info->res_num) { |
357 | info.res = | 366 | info->res = |
358 | kzalloc_node(sizeof(*info.res) * info.res_num, | 367 | kzalloc_node(sizeof(*info->res) * info->res_num, |
359 | GFP_KERNEL, controller->node); | 368 | GFP_KERNEL, controller->node); |
360 | if (!info.res) | 369 | if (!info->res) |
361 | goto out2; | 370 | goto out3; |
362 | 371 | ||
363 | info.res_offset = | 372 | info->res_offset = |
364 | kzalloc_node(sizeof(*info.res_offset) * info.res_num, | 373 | kzalloc_node(sizeof(*info->res_offset) * info->res_num, |
365 | GFP_KERNEL, controller->node); | 374 | GFP_KERNEL, controller->node); |
366 | if (!info.res_offset) | 375 | if (!info->res_offset) |
367 | goto out3; | 376 | goto out4; |
368 | 377 | ||
369 | name = kmalloc(16, GFP_KERNEL); | 378 | name = kmalloc(16, GFP_KERNEL); |
370 | if (!name) | 379 | if (!name) |
371 | goto out4; | 380 | goto out5; |
372 | 381 | ||
373 | sprintf(name, "PCI Bus %04x:%02x", domain, bus); | 382 | sprintf(name, "PCI Bus %04x:%02x", domain, bus); |
374 | info.bridge = device; | 383 | info->bridge = device; |
375 | info.controller = controller; | 384 | info->controller = controller; |
376 | info.name = name; | 385 | info->name = name; |
377 | info.res_num = 0; | 386 | info->res_num = 0; |
378 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, | 387 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, |
379 | add_window, &info); | 388 | add_window, info); |
380 | } | 389 | } |
381 | /* | 390 | /* |
382 | * See arch/x86/pci/acpi.c. | 391 | * See arch/x86/pci/acpi.c. |
@@ -385,18 +394,21 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | |||
385 | * such quirk. So we just ignore the case now. | 394 | * such quirk. So we just ignore the case now. |
386 | */ | 395 | */ |
387 | pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller, | 396 | pbus = pci_create_root_bus(NULL, bus, &pci_root_ops, controller, |
388 | &info.resources); | 397 | &info->resources); |
389 | if (!pbus) { | 398 | if (!pbus) { |
390 | pci_free_resource_list(&info.resources); | 399 | pci_free_resource_list(&info->resources); |
391 | return NULL; | 400 | return NULL; |
392 | } | 401 | } |
393 | 402 | ||
394 | pci_scan_child_bus(pbus); | 403 | pci_scan_child_bus(pbus); |
395 | return pbus; | 404 | return pbus; |
405 | |||
406 | out5: | ||
407 | kfree(info->res_offset); | ||
396 | out4: | 408 | out4: |
397 | kfree(info.res_offset); | 409 | kfree(info->res); |
398 | out3: | 410 | out3: |
399 | kfree(info.res); | 411 | kfree(info); |
400 | out2: | 412 | out2: |
401 | kfree(controller); | 413 | kfree(controller); |
402 | out1: | 414 | out1: |