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>
This commit is contained in:
parent
c3688e23a0
commit
7732e042f3
@ -352,7 +352,17 @@ void QEglFSKmsGbmScreen::flip()
|
|||||||
return;
|
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);
|
FrameBuffer *fb = framebufferForBufferObject(m_gbm_bo_next);
|
||||||
|
if (!fb) {
|
||||||
|
qWarning("FrameBuffer not available. Cannot flip");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ensureModeSet(fb->fb);
|
ensureModeSet(fb->fb);
|
||||||
|
|
||||||
const QKmsOutput &thisOutput(output());
|
const QKmsOutput &thisOutput(output());
|
||||||
@ -384,9 +394,6 @@ void QEglFSKmsGbmScreen::flip()
|
|||||||
this);
|
this);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
qErrnoWarning("Could not queue DRM page flip on screen %s", qPrintable(name()));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,12 +436,12 @@ void QEglFSKmsGbmScreen::flip()
|
|||||||
if (device()->hasAtomicSupport()) {
|
if (device()->hasAtomicSupport()) {
|
||||||
#if QT_CONFIG(drm_atomic)
|
#if QT_CONFIG(drm_atomic)
|
||||||
if (!device()->threadLocalAtomicCommit(this)) {
|
if (!device()->threadLocalAtomicCommit(this)) {
|
||||||
m_flipPending = false;
|
return;
|
||||||
gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next);
|
|
||||||
m_gbm_bo_next = nullptr;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gbmRelease.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QEglFSKmsGbmScreen::flipFinished()
|
void QEglFSKmsGbmScreen::flipFinished()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user