Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland: consistently check MAP_FAILED #6402

Merged
merged 1 commit into from
Jun 10, 2024
Merged
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
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
Loading