Commit 5a7ee55b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pci-v5.15-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull pci fix from Bjorn Helgaas:

 - Don't save msi_populate_sysfs() error code as dev->msi_irq_groups so
   we don't dereference the error code as a pointer (Wang Hai)

* tag 'pci-v5.15-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
  PCI/MSI: Handle msi_populate_sysfs() errors correctly
parents 711c3686 2b94b6b7
......@@ -535,6 +535,7 @@ static int msi_verify_entries(struct pci_dev *dev)
static int msi_capability_init(struct pci_dev *dev, int nvec,
struct irq_affinity *affd)
{
const struct attribute_group **groups;
struct msi_desc *entry;
int ret;
......@@ -558,12 +559,14 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
if (ret)
goto err;
dev->msi_irq_groups = msi_populate_sysfs(&dev->dev);
if (IS_ERR(dev->msi_irq_groups)) {
ret = PTR_ERR(dev->msi_irq_groups);
groups = msi_populate_sysfs(&dev->dev);
if (IS_ERR(groups)) {
ret = PTR_ERR(groups);
goto err;
}
dev->msi_irq_groups = groups;
/* Set MSI enabled bits */
pci_intx_for_msi(dev, 0);
pci_msi_set_enable(dev, 1);
......@@ -691,6 +694,7 @@ static void msix_mask_all(void __iomem *base, int tsize)
static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
int nvec, struct irq_affinity *affd)
{
const struct attribute_group **groups;
void __iomem *base;
int ret, tsize;
u16 control;
......@@ -730,12 +734,14 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
msix_update_entries(dev, entries);
dev->msi_irq_groups = msi_populate_sysfs(&dev->dev);
if (IS_ERR(dev->msi_irq_groups)) {
ret = PTR_ERR(dev->msi_irq_groups);
groups = msi_populate_sysfs(&dev->dev);
if (IS_ERR(groups)) {
ret = PTR_ERR(groups);
goto out_free;
}
dev->msi_irq_groups = groups;
/* Set MSI-X enabled bits and unmask the function */
pci_intx_for_msi(dev, 0);
dev->msix_enabled = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment