Merge branch 'bugfix/esp_flash_write_temp_buffer_lifetime_v4.2' into 'release/v4.2'

esp_flash: fix write issue using buffer on stack out of lifetime (v4.2)

See merge request espressif/esp-idf!17206
This commit is contained in:
Michael (XIAO Xufeng) 2022-03-15 22:14:57 +08:00
commit c2d2d58ff1

View File

@ -598,14 +598,14 @@ esp_err_t IRAM_ATTR esp_flash_write(esp_flash_t *chip, const void *buffer, uint3
do { do {
uint32_t write_len; uint32_t write_len;
const void *write_buf; const void *write_buf;
uint32_t temp_buf[8];
if (direct_write) { if (direct_write) {
write_len = MIN(length, MAX_WRITE_CHUNK); write_len = MIN(length, MAX_WRITE_CHUNK);
write_buf = buffer; write_buf = buffer;
} else { } else {
uint32_t buf[8]; write_len = MIN(length, sizeof(temp_buf));
write_len = MIN(length, sizeof(buf)); memcpy(temp_buf, buffer, write_len);
memcpy(buf, buffer, write_len); write_buf = temp_buf;
write_buf = buf;
} }
err = spiflash_start(chip); err = spiflash_start(chip);