mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi: fixed crash when calling spi_bus_free when not initialized
introduced in 49a48644e42458366b2dd7b7d153acc943d50e0f Closes: https://github.com/espressif/esp-idf/issues/8642
This commit is contained in:
parent
16ebc608db
commit
bee9b6b9eb
@ -159,7 +159,7 @@ esp_err_t spi_bus_initialize(spi_host_device_t host_id, const spi_bus_config_t *
|
|||||||
* @param host_id SPI peripheral to free
|
* @param host_id SPI peripheral to free
|
||||||
* @return
|
* @return
|
||||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||||
* - ESP_ERR_INVALID_STATE if not all devices on the bus are freed
|
* - ESP_ERR_INVALID_STATE if bus hasn't been initialized before, or not all devices on the bus are freed
|
||||||
* - ESP_OK on success
|
* - ESP_OK on success
|
||||||
*/
|
*/
|
||||||
esp_err_t spi_bus_free(spi_host_device_t host_id);
|
esp_err_t spi_bus_free(spi_host_device_t host_id);
|
||||||
|
@ -862,6 +862,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)
|
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;
|
esp_err_t err = ESP_OK;
|
||||||
spicommon_bus_context_t* ctx = bus_ctx[host_id];
|
spicommon_bus_context_t* ctx = bus_ctx[host_id];
|
||||||
spi_bus_attr_t* bus_attr = &ctx->bus_attr;
|
spi_bus_attr_t* bus_attr = &ctx->bus_attr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user