Skip to content

Commit

Permalink
PCI: Don't leak memory if sysfs_create_bin_file() fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bjorn Helgaas committed Mar 12, 2016
1 parent 9d88b93 commit b562ec8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/pci/pci-sysfs.c
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit b562ec8

Please sign in to comment.