@@ -1028,6 +1028,7 @@ static void gpiochip_set_hierarchical_irqchip(struct gpio_chip *gc,
* it is necessary to keep this around.
*/
if (is_fwnode_irqchip(gc->irq.fwnode)) {
+ struct irq_domain *domain = gc->irq.domain;
int i;
int ret;
@@ -1061,6 +1062,11 @@ static void gpiochip_set_hierarchical_irqchip(struct gpio_chip *gc,
i, ret);
continue;
}
+ if (WARN(hwirq >= domain->hwirq_max,
+ "error: hwirq 0x%x is too large for %s\n",
+ (int)hwirq, domain->name))
+ continue;
+
fwspec.fwnode = gc->irq.fwnode;
/* This is the hwirq for the GPIO line side of things */
fwspec.param[0] = hwirq;
@@ -1436,6 +1442,9 @@ static int gpiochip_to_irq(struct gpio_chip *gc, unsigned int offset)
ret = gc->irq.child_offset_to_irq(gc, offset, &hwirq);
if (ret)
return ret;
+ if (WARN(hwirq >= domain->hwirq_max,
+ "error: hwirq 0x%x is too large for %s\n", (int)hwirq, domain->name))
+ return -EINVAL;
spec.fwnode = domain->fwnode;
spec.param_count = 2;
spec.param[0] = hwirq;
Add a check to validate GPIO hwirq is always within the range of hwirq_max set in the GPIO irq domain. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> --- drivers/gpio/gpiolib.c | 9 +++++++++ 1 file changed, 9 insertions(+)