Remove calloc out of critical section. In critical section, assign allocated memory to gpio_isr_func. Free resources if gpio_isr_register() fails.