Skip to content

Commit

Permalink
genirq/msi: Check for invalid MSI parent domain usage
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Kevin Tian <[email protected]>
Acked-by: Marc Zyngier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
KAGA-KOKO committed Dec 5, 2022
1 parent e71c5d0 commit 3e86a3a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions kernel/irq/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,13 +937,21 @@ int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device

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

Expand Down Expand Up @@ -1013,6 +1021,9 @@ void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device

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);
Expand Down

0 comments on commit 3e86a3a

Please sign in to comment.