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