Merge branch 'bugfix/spi_free_crash_uninitialized' into 'master'

spi: fixed crash when calling spi_bus_free when not initialized

Closes IDFGH-7024

See merge request espressif/esp-idf!17573
This commit is contained in:
Michael (XIAO Xufeng)
2022-03-27 02:31:06 +08:00
2 changed files with 5 additions and 1 deletions

View File

@@ -864,6 +864,10 @@ const spi_bus_attr_t* spi_bus_get_attr(spi_host_device_t host_id)
esp_err_t spi_bus_free(spi_host_device_t host_id)
{
if (bus_ctx[host_id] == NULL) {
return ESP_ERR_INVALID_STATE;
}
esp_err_t err = ESP_OK;
spicommon_bus_context_t* ctx = bus_ctx[host_id];
spi_bus_attr_t* bus_attr = &ctx->bus_attr;