From eea128aa8d16eaabd021dd5ed650af5ee9c8fdea Mon Sep 17 00:00:00 2001 From: Phil Hindman Date: Fri, 11 Oct 2024 10:21:53 -0500 Subject: [PATCH] fs: shell: Allow retries after a mount failure Clean up if the mount command fails, such as due to a typo in the mount point name, so that it can be retried. Signed-off-by: Phil Hindman --- subsys/fs/shell.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subsys/fs/shell.c b/subsys/fs/shell.c index 28c7fbd4ff2..cb72b6591e7 100644 --- a/subsys/fs/shell.c +++ b/subsys/fs/shell.c @@ -777,6 +777,8 @@ static int cmd_mount_fat(const struct shell *sh, size_t argc, char **argv) if (res != 0) { shell_error(sh, "Error mounting FAT fs. Error Code [%d]", res); + k_free((void *)fatfs_mnt.mnt_point); + fatfs_mnt.mnt_point = NULL; return -ENOEXEC; } @@ -808,6 +810,8 @@ static int cmd_mount_littlefs(const struct shell *sh, size_t argc, char **argv) if (rc != 0) { shell_error(sh, "Error mounting as littlefs: %d", rc); + k_free((void *)littlefs_mnt.mnt_point); + littlefs_mnt.mnt_point = NULL; return -ENOEXEC; }