Skip to content
Snippets Groups Projects
Commit ee2affec authored by Krzysztof Swiecicki's avatar Krzysztof Swiecicki
Browse files

pmem2: fix munmap when file mapping fails (posix)

Reservation region should be unmapped only when it wasn't provided
by the config, otherwise the job of cleaning up the reservation is
up to the invoking layer.
parent 14bfb2ee
No related branches found
No related tags found
No related merge requests found
......@@ -488,8 +488,13 @@ pmem2_map_new(struct pmem2_map **map_ptr, const struct pmem2_config *cfg,
ret = file_map(reserv, content_length, proto, flags, map_fd, off,
&map_sync, &addr);
if (ret) {
/* unmap the reservation mapping */
munmap(reserv, reserved_length);
/*
* unmap the reservation mapping only
* if it wasn't provided by the config
*/
if (!cfg->reserv)
munmap(reserv, reserved_length);
if (ret == -EACCES)
ret = PMEM2_E_NO_ACCESS;
else if (ret == -ENOTSUP)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment