diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5ce0c14c637b38..a8e758989fa627 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3065,6 +3065,14 @@ int gpiod_to_irq(const struct gpio_desc *desc) return retirq; } + if (gc->irq.chip) { + /* avoid race condition with other code, which tries to lookup + * an IRQ before the irqchip has been properly registered + * (i.e. while gpiochip is still being brought up). + */ + return -EPROBE_DEFER; + } + return -ENXIO; } EXPORT_SYMBOL_GPL(gpiod_to_irq);