mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
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:
@@ -785,8 +785,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");
|
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_master_bus_handle_t i2c_master = bus_handle;
|
||||||
i2c_common_deinit_pins(i2c_master->base);
|
esp_err_t err = ESP_OK;
|
||||||
if (i2c_release_bus_handle(i2c_master->base) == 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) {
|
||||||
if (i2c_master->bus_lock_mux) {
|
if (i2c_master->bus_lock_mux) {
|
||||||
vSemaphoreDeleteWithCaps(i2c_master->bus_lock_mux);
|
vSemaphoreDeleteWithCaps(i2c_master->bus_lock_mux);
|
||||||
|
Reference in New Issue
Block a user