[uart] Clear the driver installed flag only after a successful delete

A failed uart_driver_delete leaves the old driver installed and
working; clearing the flag beforehand would gate off a live driver.
This commit is contained in:
J. Nick Koston
2026-08-16 21:16:53 -05:00
parent 575311f0e8
commit 9a7ab80c43
@@ -126,13 +126,15 @@ void IDFUARTComponent::load_settings(bool dump_config) {
esp_err_t err;
if (uart_is_driver_installed(this->uart_num_)) {
this->driver_installed_ = false;
err = uart_driver_delete(this->uart_num_);
if (err != ESP_OK) {
ESP_LOGW(TAG, "uart_driver_delete failed: %s", esp_err_to_name(err));
this->mark_failed();
return;
}
// Only mark the driver gone once the delete actually succeeded; a failed
// delete leaves the old driver installed and working
this->driver_installed_ = false;
}
err = uart_driver_install(this->uart_num_, // UART number
this->rx_buffer_size_, // RX ring buffer size