diff --git a/widget/gtk/DMABufSurface.cpp b/widget/gtk/DMABufSurface.cpp index 8d0f42444265..fab58e52c800 100644 --- a/widget/gtk/DMABufSurface.cpp +++ b/widget/gtk/DMABufSurface.cpp @@ -474,6 +474,17 @@ bool DMABufSurfaceRGBA::Create(mozilla::gl::GLContext* aGLContext, return false; } + // A broken driver can return dmabuf without valid file descriptors + // which leads to fails later so quit now. + for (int i = 0; i < mBufferPlaneCount; i++) { + if (mDmabufFds[i] < 0) { + LOGDMABUF( + (" ExportDMABUFImageMESA failed, mDmabufFds[%d] is invalid, quit", + i)); + return false; + } + } + LOGDMABUF((" imported size %d x %d format %x planes %d modifiers %" PRIx64, mWidth, mHeight, mDrmFormats[0], mBufferPlaneCount, mBufferModifiers[0]));