Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#17011] esp_vfs_fat_sdmmc_mount(): double call to free() is possible #1370

Closed
jkearins opened this issue Dec 10, 2017 · 0 comments
Closed

Comments

@jkearins
Copy link
Contributor

If f_mount() failes we will goto fail and in this case free(workbuf) will be called twice. We should reset workbuf pointer with workbuf=NULL after first call.

...
        free(workbuf); // first call
        workbuf = NULL; // <-- missed
        ESP_LOGW(TAG, "mounting again");
        res = f_mount(fs, drv, 0);
        if (res != FR_OK) {
            err = ESP_FAIL;
            ESP_LOGD(TAG, "f_mount failed after formatting (%d)", res);
            goto fail;
        }
    }
    return ESP_OK;

fail:
    sdmmc_host_deinit();
    free(workbuf); // second call
    if (fs) {
        f_mount(NULL, drv, 0);
    }
...

@FayeY FayeY changed the title esp_vfs_fat_sdmmc_mount(): double call to free() is possible [TW#17011] esp_vfs_fat_sdmmc_mount(): double call to free() is possible Dec 14, 2017
@igrr igrr closed this as completed in ed1e6e7 Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant