[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221121083325.898535631@linutronix.de>
Date: Mon, 21 Nov 2022 15:36:27 +0100 (CET)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: x86@...nel.org, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, linux-pci@...r.kernel.org,
Bjorn Helgaas <bhelgaas@...gle.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Marc Zyngier <maz@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jason Gunthorpe <jgg@...lanox.com>,
Dave Jiang <dave.jiang@...el.com>,
Alex Williamson <alex.williamson@...hat.com>,
Kevin Tian <kevin.tian@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Logan Gunthorpe <logang@...tatee.com>,
Ashok Raj <ashok.raj@...el.com>, Jon Mason <jdmason@...zu.us>,
Allen Hubbe <allenbh@...il.com>
Subject: [patch V2 07/21] genirq/msi: Check for invalid MSI parent domain usage
In the upcoming per device MSI domain concept the MSI parent domains are
not allowed to be used as regular MSI domains where the MSI allocation/free
operations are applicable.
Add appropriate checks.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
V2: Made the error return understandable. (Kevin)
---
kernel/irq/msi.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -937,13 +937,21 @@ int msi_domain_alloc_irqs_descs_locked(s
lockdep_assert_held(&dev->msi.data->mutex);
+ if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain))) {
+ ret = -EINVAL;
+ goto free;
+ }
+
+ /* Frees allocated descriptors in case of failure. */
ret = msi_domain_add_simple_msi_descs(info, dev, nvec);
if (ret)
- return ret;
+ goto free;
ret = ops->domain_alloc_irqs(domain, dev, nvec);
- if (ret)
- msi_domain_free_irqs_descs_locked(domain, dev);
+ if (!ret)
+ return 0;
+free:
+ msi_domain_free_irqs_descs_locked(domain, dev);
return ret;
}
@@ -1013,6 +1021,9 @@ void msi_domain_free_irqs_descs_locked(s
lockdep_assert_held(&dev->msi.data->mutex);
+ if (WARN_ON_ONCE(irq_domain_is_msi_parent(domain)))
+ return;
+
ops->domain_free_irqs(domain, dev);
if (ops->msi_post_free)
ops->msi_post_free(domain, dev);
Powered by blists - more mailing lists