summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Senyk <thomas.senyk@qt.io>2022-12-12 15:03:00 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-12-13 20:08:00 +0000
commit7732e042f3b31d0b63b7dd25d3948ef3f50a3efd (patch)
tree24feaf4cec54004b4be194a3c424fa70468ff83d
parentc3688e23a0140a59328514248ca7c03660164efd (diff)
downloadqtbase-7732e042f3b31d0b63b7dd25d3948ef3f50a3efd.tar.gz
eglfs-kms/gbm: fix segfault and add qScopeGuard
As framebufferForBufferObject has a code-path which returns a nullptr, it's vital to check on that and return early in that case. As this is the third segment in this function that does gbm_surface_release_buffer, a qScopeGuard was introduced to reduce code duplication. This also makes this function saver/easier to maintain long term. The platform on which this segfault was reported is QEMU Change-Id: I5ee1ad4073712349b7475bce3a7978961fea2344 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit ad2aca113daccb4d0e9299b7c37d61f2d9b1f930) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index 0f829ee00c..e6fd627823 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -352,7 +352,17 @@ void QEglFSKmsGbmScreen::flip()
return;
}
+ auto gbmRelease = qScopeGuard([this]{
+ m_flipPending = false;
+ gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
+ m_gbm_bo_next = nullptr;
+ });
+
FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next);
+ if (!fb) {
+ qWarning("FrameBuffer not available. Cannot flip");
+ return;
+ }
ensureModeSet(fb->fb);
const QKmsOutput &thisOutput(output());
@@ -384,9 +394,6 @@ void QEglFSKmsGbmScreen::flip()
this);
if (ret) {
qErrnoWarning("Could not queue DRM page flip on screen %s", qPrintable(name()));
- m_flipPending = false;
- gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
- m_gbm_bo_next = nullptr;
return;
}
}
@@ -429,12 +436,12 @@ void QEglFSKmsGbmScreen::flip()
if (device()->hasAtomicSupport()) {
#if QT_CONFIG(drm_atomic)
if (!device()->threadLocalAtomicCommit(this)) {
- m_flipPending = false;
- gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
- m_gbm_bo_next = nullptr;
+ return;
}
#endif
}
+
+ gbmRelease.dismiss();
}
void QEglFSKmsGbmScreen::flipFinished()