From 4468981c1c50999f315baa1508f0e53c4ee70c52 Mon Sep 17 00:00:00 2001 From: Ziyao Date: Mon, 18 Nov 2024 19:43:51 +0000 Subject: [PATCH] drm: Validate conn before dereference in CDRMAtomicRequest::commit() (#108) 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: https://github.com/hyprwm/aquamarine/issues/107 Signed-off-by: Yao Zi --- src/backend/drm/impl/Atomic.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/drm/impl/Atomic.cpp b/src/backend/drm/impl/Atomic.cpp index b031076..2eae330 100644 --- a/src/backend/drm/impl/Atomic.cpp +++ b/src/backend/drm/impl/Atomic.cpp @@ -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))); @@ -365,4 +368,4 @@ bool Aquamarine::CDRMAtomicImpl::moveCursor(SP connector, bool sk } return true; -} \ No newline at end of file +}