1.1 --- a/libfsclient/lib/src/file.cc Thu Oct 20 23:04:46 2022 +0200
1.2 +++ b/libfsclient/lib/src/file.cc Thu Oct 20 23:06:31 2022 +0200
1.3 @@ -356,12 +356,16 @@
1.4 offset_t start_visible, offset_t end_visible,
1.5 l4re_rm_flags_t region_flags)
1.6 {
1.7 - char *memory = file->memory;
1.8 long err = file_mmap_only(file, position, length, start_visible, end_visible);
1.9
1.10 if (err)
1.11 return err;
1.12
1.13 + if (file->memory != NULL)
1.14 + ipc_detach_dataspace(file->memory);
1.15 +
1.16 + file->memory = NULL;
1.17 +
1.18 err = ipc_attach_dataspace_align(file->ref, file_span(file),
1.19 L4RE_RM_F_SEARCH_ADDR | region_flags,
1.20 L4_PAGESHIFT,
1.21 @@ -369,9 +373,6 @@
1.22 if (err)
1.23 return err;
1.24
1.25 - if (memory != NULL)
1.26 - ipc_detach_dataspace(memory);
1.27 -
1.28 return L4_EOK;
1.29 }
1.30
1.31 @@ -722,20 +723,20 @@
1.32 {
1.33 client_Pipe _pipe(pipe->ref);
1.34 long err = _pipe.next_region(&pipe->data_end, &pipe->size);
1.35 - char *memory = pipe->memory;
1.36
1.37 if (err)
1.38 return err;
1.39
1.40 + if (pipe->memory != NULL)
1.41 + ipc_detach_dataspace(pipe->memory);
1.42 +
1.43 pipe->end_pos = pipe->size;
1.44 + pipe->memory = NULL;
1.45
1.46 err = ipc_attach_dataspace(pipe->ref, file_span(pipe), (void **) &pipe->memory);
1.47 if (err)
1.48 return err;
1.49
1.50 - if (memory != NULL)
1.51 - ipc_detach_dataspace(memory);
1.52 -
1.53 return L4_EOK;
1.54 }
1.55