kopia lustrzana https://github.com/espressif/esp-idf
spi_flash: make {get,release}_temp_buffer OS functions optional
Fixes a crash when calling a NULL release_temp_buffer pointer throug esp_flash_noos_functions, when doing a core dump.pull/5688/head
rodzic
ef3280295d
commit
75a874d4fd
|
@ -562,8 +562,10 @@ esp_err_t IRAM_ATTR esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t add
|
|||
|
||||
if (!direct_read) {
|
||||
size_t actual_len = 0;
|
||||
temp_buffer = chip->os_func->get_temp_buffer(chip->os_func_data, read_chunk_size, &actual_len);
|
||||
read_chunk_size = actual_len;
|
||||
if (chip->os_func->get_temp_buffer != NULL) {
|
||||
temp_buffer = chip->os_func->get_temp_buffer(chip->os_func_data, read_chunk_size, &actual_len);
|
||||
read_chunk_size = actual_len;
|
||||
}
|
||||
if (temp_buffer == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
@ -600,7 +602,9 @@ esp_err_t IRAM_ATTR esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t add
|
|||
buffer = (void*)((intptr_t)buffer + length_to_read);
|
||||
} while (err == ESP_OK && length > 0);
|
||||
|
||||
chip->os_func->release_temp_buffer(chip->os_func_data, temp_buffer);
|
||||
if (chip->os_func->release_temp_buffer != NULL) {
|
||||
chip->os_func->release_temp_buffer(chip->os_func_data, temp_buffer);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,19 +70,14 @@ static IRAM_ATTR esp_err_t delay_us(void *arg, unsigned us)
|
|||
return ESP_OK;
|
||||
}
|
||||
|
||||
// Currently when the os is not up yet, the caller is supposed to call esp_flash APIs with proper
|
||||
// buffers.
|
||||
IRAM_ATTR void* get_temp_buffer_not_supported(void* arg, size_t reqest_size, size_t* out_size)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const DRAM_ATTR esp_flash_os_functions_t esp_flash_noos_functions = {
|
||||
.start = start,
|
||||
.end = end,
|
||||
.delay_us = delay_us,
|
||||
.region_protected = NULL,
|
||||
.get_temp_buffer = get_temp_buffer_not_supported,
|
||||
/* the caller is supposed to call esp_flash_read/esp_flash_write APIs with buffers in DRAM */
|
||||
.get_temp_buffer = NULL,
|
||||
.release_temp_buffer = NULL,
|
||||
.yield = NULL,
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue