On success, munmap() returns 0. On failure, it returns -1, and errno is set to indicate the cause of the error (probably to EINVAL).
ERRORS
EACCES A file descriptor refers to a non-regular file. Or a file mapping was requested, but fd is not open for reading. Or MAP_SHARED was requested and PROT_WRITE is set, but fd is not open in
read/write (O_RDWR) mode. Or PROT_WRITE is set, but the file is append-only.
EAGAIN The file has been locked, or too much memory has been locked (see setrlimit(2)).
EBADF fd is not a valid file descriptor (and MAP_ANONYMOUS was not set).
EEXIST MAP_FIXED_NOREPLACE was specified in flags, and the range covered by addr and length clashes with an existing mapping.
EINVAL We don't like addr, length, or offset (e.g., they are too large, or
not aligned on a page boundary).