Commit bc0207a5 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Linus Walleij

gpiolib: avoid uninitialized data in gpio kfifo

gcc reports a theoretical case for returning uninitialized data in
the kfifo when a GPIO interrupt happens and neither
GPIOEVENT_REQUEST_RISING_EDGE nor GPIOEVENT_REQUEST_FALLING_EDGE
are set:

drivers/gpio/gpiolib.c: In function 'lineevent_irq_thread':
drivers/gpio/gpiolib.c:683:87: error: 'ge.id' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This case should not happen, but to be on the safe side, let's
return from the irq handler without adding data to the FIFO
to ensure we can never leak stack data to user space.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Fixes: 61f922db ("gpio: userspace ABI for reading GPIO line events")
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 97f69747
...@@ -674,6 +674,8 @@ irqreturn_t lineevent_irq_thread(int irq, void *p) ...@@ -674,6 +674,8 @@ irqreturn_t lineevent_irq_thread(int irq, void *p)
} else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) { } else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {
/* Emit high-to-low event */ /* Emit high-to-low event */
ge.id = GPIOEVENT_EVENT_FALLING_EDGE; ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
} else {
return IRQ_NONE;
} }
ret = kfifo_put(&le->events, ge); ret = kfifo_put(&le->events, ge);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment