Skip to contentSkip to conversation

irqchip/gic: add WARN_ON() to facilitate backtracking

PATCH In review Yejune Deng 2 participants 3 messages Dec 29, 2020 – Dec 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irqchip/gic: add WARN_ON() to facilitate backtracking

There is two function gic_of_init() and gic_of_init_child() called gic_of_setup(),so add WARN_ON() to facilitate backtracking.

---
 drivers/irqchip/irq-gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic.c +1 -1
index b1d9c22..7c11705 100644
@@ -1380,7 +1380,7 @@ static bool gic_check_eoimode(struct device_node *node, void __iomem **base)
 
 static int gic_of_setup(struct gic_chip_data *gic, struct device_node *node)
 {
-	if (!gic || !node)
+	if (WARN_ON(!gic || !node))
 		return -EINVAL;
 
 	gic->raw_dist_base = of_iomap(node, 0);
Signature · 1 line
1.9.1
maintainer
#1 lore raw

Yejune,

Quoted 22 lines · Yejune Deng

There is two function gic_of_init() and gic_of_init_child() called gic_of_setup(),so add WARN_ON() to facilitate backtracking.

---
 drivers/irqchip/irq-gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic.c +1 -1
index b1d9c22..7c11705 100644
@@ -1380,7 +1380,7 @@ static bool gic_check_eoimode(struct device_node
 *node, void __iomem **base)
 
 static int gic_of_setup(struct gic_chip_data *gic, struct device_node 
 *node)
 {
-	if (!gic || !node)
+	if (WARN_ON(!gic || !node))
 		return -EINVAL;
Quoted 1 line

gic->raw_dist_base = of_iomap(node, 0);

I don't immediately see what you gain with this. If you end-up here with NULL pointers, that either because:

- you have failed to allocate the GIC private data structure:
but as it turns out, these allocations either cannot fail (gic_data[] is static), or the dynamic allocation in gic_of_init_child() is
already
checked.

- node is NULL: both paths already check for a NULL node, so that cannot fail either.

My conclusion is that these checks can never trigger, and we should be able to *remove* them altogether.

Am I missing something?

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#2 lore raw

OK,I will adopt it and resubmit.

Quoted 48 lines · Marc Zyngier

Yejune,

Quoted 22 lines · Yejune Deng

There is two function gic_of_init() and gic_of_init_child() called gic_of_setup(),so add WARN_ON() to facilitate backtracking.

---
 drivers/irqchip/irq-gic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic.c +1 -1
index b1d9c22..7c11705 100644
@@ -1380,7 +1380,7 @@ static bool gic_check_eoimode(struct device_node
 *node, void __iomem **base)
 
 static int gic_of_setup(struct gic_chip_data *gic, struct device_node
 *node)
 {
-     if (!gic || !node)
+     if (WARN_ON(!gic || !node))
              return -EINVAL;
Quoted 1 line
      gic->raw_dist_base = of_iomap(node, 0);

I don't immediately see what you gain with this. If you end-up here with NULL pointers, that either because:

- you have failed to allocate the GIC private data structure:
but as it turns out, these allocations either cannot fail (gic_data[] is static), or the dynamic allocation in gic_of_init_child() is
already
checked.

- node is NULL: both paths already check for a NULL node, so that cannot fail either.

My conclusion is that these checks can never trigger, and we should be able to *remove* them altogether.

Am I missing something?

         M.

--
Jazz is not dead. It just smells funny...