forked from espressif/esp-idf
fix(i2c): Add bus handle check so that it will not be panic when there is no free bus,
Closes https://github.com/espressif/esp-idf/issues/14819
This commit is contained in:
@@ -784,8 +784,12 @@ static esp_err_t i2c_master_bus_destroy(i2c_master_bus_handle_t bus_handle)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(bus_handle, ESP_ERR_INVALID_ARG, TAG, "no memory for i2c master bus");
|
||||
i2c_master_bus_handle_t i2c_master = bus_handle;
|
||||
i2c_common_deinit_pins(i2c_master->base);
|
||||
if (i2c_release_bus_handle(i2c_master->base) == ESP_OK) {
|
||||
esp_err_t err = ESP_OK;
|
||||
if (i2c_master->base) {
|
||||
i2c_common_deinit_pins(i2c_master->base);
|
||||
err = i2c_release_bus_handle(i2c_master->base);
|
||||
}
|
||||
if (err == ESP_OK) {
|
||||
if (i2c_master) {
|
||||
if (i2c_master->bus_lock_mux) {
|
||||
vSemaphoreDeleteWithCaps(i2c_master->bus_lock_mux);
|
||||
|
Reference in New Issue
Block a user