mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_gpio_driver_calloc_v4.4' into 'release/v4.4'
fix(gpio): fix potential crash when processing gpio isr (v4.4) See merge request espressif/esp-idf!24903
This commit is contained in:
commit
cc484c59c8
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -7,6 +7,7 @@
|
||||
#include <esp_types.h>
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "soc/soc.h"
|
||||
@ -448,8 +449,9 @@ esp_err_t gpio_install_isr_service(int intr_alloc_flags)
|
||||
{
|
||||
GPIO_CHECK(gpio_context.gpio_isr_func == NULL, "GPIO isr service already installed", ESP_ERR_INVALID_STATE);
|
||||
esp_err_t ret;
|
||||
const uint32_t alloc_caps = (intr_alloc_flags & ESP_INTR_FLAG_IRAM) ? MALLOC_CAP_INTERNAL : MALLOC_CAP_DEFAULT;
|
||||
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
gpio_context.gpio_isr_func = (gpio_isr_func_t *) calloc(GPIO_NUM_MAX, sizeof(gpio_isr_func_t));
|
||||
gpio_context.gpio_isr_func = (gpio_isr_func_t *) heap_caps_calloc(GPIO_NUM_MAX, sizeof(gpio_isr_func_t), alloc_caps);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
if (gpio_context.gpio_isr_func == NULL) {
|
||||
ret = ESP_ERR_NO_MEM;
|
||||
|
Loading…
Reference in New Issue
Block a user