Commit 5e46c775 authored by Roger Pau Monne's avatar Roger Pau Monne Committed by Khalid Elmously

xen/pirq: fix error path cleanup when binding MSIs

BugLink: https://bugs.launchpad.net/bugs/1775771

[ Upstream commit 910f8bef ]

Current cleanup in the error path of xen_bind_pirq_msi_to_irq is
wrong. First of all there's an off-by-one in the cleanup loop, which
can lead to unbinding wrong IRQs.

Secondly IRQs not bound won't be freed, thus leaking IRQ numbers.

Note that there's no need to differentiate between bound and unbound
IRQs when freeing them, __unbind_from_irq will deal with both of them
correctly.

Fixes: 4892c9b4 ("xen: add support for MSI message groups")
Reported-by: default avatarHooman Mirhadi <mirhadih@amazon.com>
Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
Reviewed-by: default avatarAmit Shah <aams@amazon.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 2ae6be7a
...@@ -764,8 +764,8 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, ...@@ -764,8 +764,8 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc,
mutex_unlock(&irq_mapping_update_lock); mutex_unlock(&irq_mapping_update_lock);
return irq; return irq;
error_irq: error_irq:
for (; i >= 0; i--) while (nvec--)
__unbind_from_irq(irq + i); __unbind_from_irq(irq + nvec);
mutex_unlock(&irq_mapping_update_lock); mutex_unlock(&irq_mapping_update_lock);
return ret; return ret;
} }
......
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