Skip to content

Commit 103cf62

Browse files
committed
Merge branch 'bugfix/unmount_crash' into 'master'
esp_peripherals: fix unmount crash is not mounted See merge request adf/esp-adf-internal!1215
2 parents 20c0835 + a3f1da9 commit 103cf62

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/esp_peripherals/periph_sdcard.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ static const char *TAG = "PERIPH_SDCARD";
4343

4444
#define tick_get periph_tick_get
4545

46-
4746
static esp_err_t periph_sdcard_mount(esp_periph_handle_t periph);
4847
static esp_err_t periph_sdcard_unmount(esp_periph_handle_t periph);
4948

50-
5149
typedef struct {
5250
char *root;
5351
int card_detect_pin;
@@ -106,13 +104,15 @@ static esp_err_t _sdcard_destroy(esp_periph_handle_t self)
106104
{
107105
VALIDATE_SDCARD(self, ESP_FAIL);
108106
esp_err_t ret = ESP_OK;
109-
110-
ret |= sdcard_unmount();
107+
periph_sdcard_t *sdcard = esp_periph_get_data(self);
108+
if (sdcard->is_mounted) {
109+
ret |= sdcard_unmount();
110+
sdcard->is_mounted = false;
111+
}
111112
ret |= sdcard_destroy();
112113
if (ret != ESP_OK) {
113114
ESP_LOGE(TAG, "stop sdcard error!");
114115
}
115-
periph_sdcard_t *sdcard = esp_periph_get_data(self);
116116
esp_periph_stop_timer(self);
117117
audio_free(sdcard->root);
118118
audio_free(sdcard);

0 commit comments

Comments
 (0)