Skip to content

Commit

Permalink
drm: Validate conn before dereference in CDRMAtomicRequest::commit()
Browse files Browse the repository at this point in the history
During startup, CDRMAtomicImpl::reset() may emit a call to method
commit of a CDRMAtomicRequest instance with member "conn" uninitialized,
leading to a segfault. Validate the the pointer before dereference it as
a workaround.

Fixes: 55ac962 ("DRM: preliminary atomic support")
Closes: #107
Signed-off-by: Yao Zi <[email protected]>
  • Loading branch information
ziyao233 committed Nov 18, 2024
1 parent b31a6a4 commit ba2c89b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/backend/drm/impl/Atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ bool Aquamarine::CDRMAtomicRequest::commit(uint32_t flagssss) {
return false;
}

if (!conn)
return false;

if (auto ret = drmModeAtomicCommit(backend->gpu->fd, req, flagssss, &conn->pendingPageFlip); ret) {
backend->log((flagssss & DRM_MODE_ATOMIC_TEST_ONLY) ? AQ_LOG_DEBUG : AQ_LOG_ERROR,
std::format("atomic drm request: failed to commit: {}, flags: {}", strerror(-ret), flagsToStr(flagssss)));
Expand Down Expand Up @@ -365,4 +368,4 @@ bool Aquamarine::CDRMAtomicImpl::moveCursor(SP<SDRMConnector> connector, bool sk
}

return true;
}
}

0 comments on commit ba2c89b

Please sign in to comment.