Skip to content

Commit

Permalink
wayland: consistently check mmap error after 6967a31 (#6402)
Browse files Browse the repository at this point in the history
mmap() returns MAP_FAILED on error, not nullptr.
  • Loading branch information
jbeich committed Jun 10, 2024
1 parent ea2501d commit 811429b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/protocols/LinuxDMABUF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CCompiledDMABUFFeedback::CCompiledDMABUFFeedback(dev_t device, std::vector<SDMAB

auto arr = (SDMABUFFeedbackTableEntry*)mmap(nullptr, tableLen, PROT_READ | PROT_WRITE, MAP_SHARED, fds[0], 0);

if (!arr) {
if (arr == MAP_FAILED) {
LOGM(ERR, "mmap failed");
close(fds[0]);
close(fds[1]);
Expand Down
4 changes: 2 additions & 2 deletions src/protocols/core/Shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void CSHMPool::resize(size_t size_) {
size = size_;
data = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

if (!data)
if (data == MAP_FAILED)
LOGM(ERR, "Couldn't mmap {} bytes from fd {} of shm client", size, fd);
}

Expand Down Expand Up @@ -146,7 +146,7 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, int fd_, size_t
RESOURCE->resource->buffer = RESOURCE;
});

if (!pool->data)
if (pool->data == MAP_FAILED)
resource->error(WL_SHM_ERROR_INVALID_FD, "Couldn't mmap from fd");
}

Expand Down

0 comments on commit 811429b

Please sign in to comment.