Skip to content

Conversation

mac-michael
Copy link

If mgos_gpio_clear_int is called in an interrupt callback cnt is set to 0 in the clear function.
Then it's decremented in mgos_gpio_int_cb: 0-1=2^16-1 which can start an infinite loop.

IRAM void mgos_gpio_clear_int(int pin) {
  struct mgos_gpio_state *s = mgos_gpio_get_state(pin);
  if (s == NULL) return;
  mgos_gpio_hal_clear_int(pin);
  s->cnt = 0;
}

static void mgos_gpio_int_cb(void *arg) {
[...]
  if (s->button.debounce_ms == 0) {
    while (s->cnt > 0) {
      mgos_runlock(s_lock);
      s->cb(pin, s->cb_arg);
      mgos_rlock(s_lock);
      s->cnt--;
    }
  } [...]
}

@mac-michael
Copy link
Author

Are there any chances to merge this pull request? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant