diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2016-03-10 21:36:28 +0100 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-03-12 13:00:29 +0100 |
commit | b562ec8f74e4edb532a53d26f0002d6fb4a6c79b (patch) | |
tree | 937dc632aa3aff0e824cd6575698ef7418ae47da /drivers/pci/pci-sysfs.c | |
parent | PCI: Simplify sysfs ROM cleanup (diff) | |
download | linux-b562ec8f74e4edb532a53d26f0002d6fb4a6c79b.tar.xz linux-b562ec8f74e4edb532a53d26f0002d6fb4a6c79b.zip |
PCI: Don't leak memory if sysfs_create_bin_file() fails
If sysfs_create_bin_file() fails, pci_create_attr() leaks the struct
bin_attribute it allocated previously.
Free the struct bin_attribute if pci_create_attr() fails.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 4ca8af3d5eda..847a97351030 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1159,6 +1159,8 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine) res_attr->size = pci_resource_len(pdev, num); res_attr->private = &pdev->resource[num]; retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); + if (retval) + kfree(res_attr); } else retval = -ENOMEM; |