pci-v5.15-fixes-2

-----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAmFp1zoUHGJoZWxnYWFz
 QGdvb2dsZS5jb20ACgkQWYigwDrT+vxJbxAAjZi//M1Cz3PiONx3y9ipYX6THN2g
 yXvEnkB6ECwZgq3a68jD5fS+GCw/SDg+I64zlZKqXlefqxjKXIh2R/naguyM27tK
 hndMnS9m2lSJ5ro2DCqBGswBNB2HhVkglsuV9CEJQhSEB4zRt1xphYcklq+ouBjc
 Z+fG0zASPtMs/eWFTaQ3XYUlfko+819sk1H+03GTa2ue0wYzidrxZlcNZ3UNB8rf
 LUagMUqqpNC3FSipAwc/fhVxVSg5zNw6ZgUh8bEI75qsfoSkiaeIrrc+onf/FbgG
 nn381M0wTBcn8nwUqLxtwKcAHk5/jvUYdJ145JgC/7OG/8SamXh3ETK7IMFUrxzk
 7rLpa+R7iOSdJz2ytGbqS3ZAd0yAOoEzYrc7ndFquHS1I5zWvwZ+aDaKVz1OUIr2
 pONSizlh6efAI8jwWgHLAbVBCxROWV3jqvNBlF/pkgIFbHZeWdpumz/k6MWuswrt
 mjSnauk58XPdK/NAEPX02lWwoPD8kLSqQXOuELpC3vuwdGLwl+vkWrgYt4XgTlWi
 gFsfAhDw7sSe69/hbsgMhtN2DIshI+pnAWXI5WFXaWpcPlYbGWbDwyS1Be7TTj/J
 rM2aCURf03oQyhu0uRFRIzphaZoIE+QX+Dzsmk7bcR75fw0nw5GLQdTuDxEtnw7P
 2qyNLiFZHHA0AqY=
 =JRLg
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2021-10-16 09:00:46 -07:00
commit 5a7ee55b1f

View File

@ -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;