diff options
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index cd913a2a416f..284e83a527f9 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -620,7 +620,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
620 | goto err_bin_file; | 620 | goto err_bin_file; |
621 | 621 | ||
622 | /* If the device has a ROM, try to expose it in sysfs. */ | 622 | /* If the device has a ROM, try to expose it in sysfs. */ |
623 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { | 623 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE) || |
624 | (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) { | ||
624 | rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); | 625 | rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); |
625 | if (rom_attr) { | 626 | if (rom_attr) { |
626 | pdev->rom_attr = rom_attr; | 627 | pdev->rom_attr = rom_attr; |
@@ -635,7 +636,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
635 | goto err_rom; | 636 | goto err_rom; |
636 | } else { | 637 | } else { |
637 | retval = -ENOMEM; | 638 | retval = -ENOMEM; |
638 | goto err_bin_file; | 639 | goto err_resource_files; |
639 | } | 640 | } |
640 | } | 641 | } |
641 | /* add platform-specific attributes */ | 642 | /* add platform-specific attributes */ |
@@ -645,6 +646,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) | |||
645 | 646 | ||
646 | err_rom: | 647 | err_rom: |
647 | kfree(rom_attr); | 648 | kfree(rom_attr); |
649 | err_resource_files: | ||
650 | pci_remove_resource_files(pdev); | ||
648 | err_bin_file: | 651 | err_bin_file: |
649 | if (pdev->cfg_size < 4096) | 652 | if (pdev->cfg_size < 4096) |
650 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); | 653 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); |
@@ -695,4 +698,4 @@ static int __init pci_sysfs_init(void) | |||
695 | return 0; | 698 | return 0; |
696 | } | 699 | } |
697 | 700 | ||
698 | __initcall(pci_sysfs_init); | 701 | late_initcall(pci_sysfs_init); |