Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/fs/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ status_t fs_open_file(const char *path, filehandle **handle) {
}

filehandle *f = malloc(sizeof(*f));
if (!f) {
mount->api->close(cookie);
put_mount(mount);
return ERR_NO_MEMORY;
}
f->cookie = cookie;
f->mount = mount;
*handle = f;
Expand Down Expand Up @@ -309,8 +314,9 @@ status_t fs_create_file(const char *path, filehandle **handle, uint64_t len) {

filehandle *f = malloc(sizeof(*f));
if (!f) {
mount->api->close(cookie);
put_mount(mount);
return err;
return ERR_NO_MEMORY;
}
f->cookie = cookie;
f->mount = mount;
Expand Down Expand Up @@ -425,6 +431,7 @@ status_t fs_open_dir(const char *path, dirhandle **handle) {

dirhandle *d = malloc(sizeof(*d));
if (!d) {
mount->api->closedir(cookie);
put_mount(mount);
return ERR_NO_MEMORY;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/libc/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ FILE *fopen(const char *filename, const char *mode) {

int fclose(FILE *stream) {
#if defined(WITH_LIB_FS)
if (stream && !stream->use_fs) {
if (stream && stream->use_fs) {
fs_close_file(stream->fs_handle.handle);
free(stream);
}
Expand Down