On Thu, Mar 10, 2022 at 3:22 PM Shreeya Patel
<shreeya.patel@xxxxxxxxxxxxx> wrote:
gc irq members are exposed before they could be completelyFixes tag?
initialized and this leads to race conditions.
One such issue was observed for the gc->irq.domain variable which
was accessed through the I2C interface in gpiochip_to_irq() before
it could be initialized by gpiochip_add_irqchip(). This resulted in
Kernel NULL pointer dereference.
To avoid such scenarios, restrict usage of gc irq members before
they are completely initialized.
...
+bool gc_irq_initialized;Non-static?
Why is it global?
...
@@ -1593,6 +1594,8 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc,This is wrong. Imagine a system where you have more than one GPIO chip.
acpi_gpiochip_request_interrupts(gc);
+ gc_irq_initialized = true;
...
- if (gc->to_irq) {Shouldn't it rather be something like
+ if (gc->to_irq && gc_irq_initialized) {
int retirq = gc->to_irq(gc, offset);
if (gc->to_irq) {
if (! ..._initialized)
return -EPROBE_DEFER;
...
}
?
--
With Best Regards,
Andy Shevchenko