[PATCH 4/5] genirq/irqdomain: Simplify the checks for irq_domain_push/pop_irq()

From: Jinjie Ruan
Date: Mon May 06 2024 - 09:04:07 EST


Since whether desc is NULL or domain is NULL or irq_data is NULL, it
returns -EINVAL, check them together in irq_domain_push/pop_irq(). And
whether the irq domain is not hierarchy or it's parent domain is not
consistent, it returns -EINVAL, check them together too.

Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
kernel/irq/irqdomain.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 6d8a368c677b..2ef53697d877 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1613,21 +1613,14 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg)
* to deadlock, so we just do a simple check before starting.
*/
desc = irq_to_desc(virq);
- if (!desc)
+ if (!desc || !domain || !irq_data)
return -EINVAL;
+
if (WARN_ON(desc->action))
return -EBUSY;

- if (domain == NULL)
- return -EINVAL;
-
- if (WARN_ON(!irq_domain_is_hierarchy(domain)))
- return -EINVAL;
-
- if (!irq_data)
- return -EINVAL;
-
- if (domain->parent != irq_data->domain)
+ if (WARN_ON(!irq_domain_is_hierarchy(domain)) ||
+ domain->parent != irq_data->domain)
return -EINVAL;

parent_irq_data = kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL,
@@ -1694,17 +1687,11 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq)
* deadlock, so we just do a simple check before starting.
*/
desc = irq_to_desc(virq);
- if (!desc)
+ if (!desc || !domain || !irq_data)
return -EINVAL;
if (WARN_ON(desc->action))
return -EBUSY;

- if (domain == NULL)
- return -EINVAL;
-
- if (!irq_data)
- return -EINVAL;
-
tmp_irq_data = irq_domain_get_irq_data(domain, virq);

/* We can only "pop" if this domain is at the top of the list */
--
2.34.1