mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
hal: spi_flash: avoid calling memcpy with NULL buffer
In practice, calling memcpy with NULL buffer and 0 size works on the ESP32, but the C standard considers this an undefined behavior. When building with UBSAN checks enabled, compiler will insert a check that memcpy argument is non-NULL, regardless of the size argument. This caused a failure in tools/test_apps/system/panic, which is built with USBAN enabled for several components.
This commit is contained in:
parent
d838a11d78
commit
1d44e40fb1
@ -174,7 +174,9 @@ esp_err_t spi_flash_hal_common_command(spi_flash_host_inst_t *host, spi_flash_tr
|
||||
spi_flash_ll_set_miso_bitlen(dev, trans->miso_len * 8);
|
||||
spi_flash_ll_user_start(dev);
|
||||
host->driver->poll_cmd_done(host);
|
||||
spi_flash_ll_get_buffer_data(dev, trans->miso_data, trans->miso_len);
|
||||
if (trans->miso_len > 0) {
|
||||
spi_flash_ll_get_buffer_data(dev, trans->miso_data, trans->miso_len);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -188,6 +190,8 @@ esp_err_t spi_flash_hal_read(spi_flash_host_inst_t *host, void *buffer, uint32_t
|
||||
spi_flash_ll_set_miso_bitlen(dev, read_len * 8);
|
||||
spi_flash_ll_user_start(dev);
|
||||
host->driver->poll_cmd_done(host);
|
||||
spi_flash_ll_get_buffer_data(dev, buffer, read_len);
|
||||
if (read_len > 0) {
|
||||
spi_flash_ll_get_buffer_data(dev, buffer, read_len);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user