[plasma/kwin] /: autotests/integration/drm_test: don't crash if buffer allocation fails
Xaver Hugl <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit c5236b4e375ebebe0cef2b58e5d871540c93804a by Xaver Hugl.
Committed on 16/07/2026 at 18:38.
Pushed by zamundaaa into branch 'master'.
autotests/integration/drm_test: don't crash if buffer allocation fails
M +10 -1 autotests/integration/drm_test.cpp
M +1 -1 src/backends/drm/drm_gpu.cpp
https://invent.kde.org/plasma/kwin/-/commit/c5236b4e375ebebe0cef2b58e5d871540c93804a
diff --git a/autotests/integration/drm_test.cpp b/autotests/integration/drm_test.cpp
index eef543a9be2..9689e4b4a7d 100644
--- a/autotests/integration/drm_test.cpp
+++ b/autotests/integration/drm_test.cpp
@@ -244,6 +244,10 @@ public:
.software = false,
.scanout = false,
});
+ if (!m_buffer) {
+ qWarning("Allocating initial buffer on %s failed! %s", qPrintable(m_device->path()), strerror(errno));
+ return false;
+ }
auto wlbuffer = Test::linuxDmabuf()->importBuffer(m_buffer.buffer());
m_surface->attachBuffer(wlbuffer);
m_surface->damage(QRect(QPoint(0, 0), size));
@@ -266,13 +270,18 @@ public:
if (!device) {
continue;
}
- m_buffer = device->allocator()->allocate(GraphicsBufferOptions{
+ auto buffer = device->allocator()->allocate(GraphicsBufferOptions{
.size = m_buffer->size(),
.format = m_buffer->dmabufAttributes()->format,
.modifiers = tranche.formats[m_buffer->dmabufAttributes()->format],
.software = false,
.scanout = tranche.scanout,
});
+ if (!buffer) {
+ qWarning("Allocating buffer on %s failed! %s", qPrintable(device->path()), strerror(errno));
+ continue;
+ }
+ m_buffer = buffer;
auto wlbuffer = Test::linuxDmabuf()->importBuffer(m_buffer.buffer());
m_surface->attachBuffer(wlbuffer);
m_surface->damage(QRect(QPoint(0, 0), m_buffer->size()));
diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp
index b089b055296..e54e3767c9e 100644
--- a/src/backends/drm/drm_gpu.cpp
+++ b/src/backends/drm/drm_gpu.cpp
@@ -1005,7 +1005,7 @@ std::shared_ptr<DrmFramebuffer> DrmGpu::importBuffer(GraphicsBuffer *buffer, Fil
});
for (int i = 0; i < attributes->planeCount; ++i) {
if (drmPrimeFDToHandle(m_fd, attributes->fd[i].get(), &handles[i]) != 0) {
- qCWarning(KWIN_DRM) << "drmPrimeFDToHandle() failed";
+ qCWarning(KWIN_DRM, "drmPrimeFDToHandle failed: %s", strerror(errno));
return nullptr;
}
}