From patchwork Fri Jun 6 04:36:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: render: Don't generate invalid pixman format when using a 24bpp framebuffer with a 32bit depth visual. From: Robert Ancell X-Patchwork-Id: 27240 Message-Id: <1402029419-6400-1-git-send-email-robert.ancell@canonical.com> To: xorg-devel@lists.x.org Cc: Robert Ancell Date: Fri, 6 Jun 2014 16:36:59 +1200 When using the fb backend at 24bpp it allows a visual with 32 bit depth. This would cause RENDER to try and create an invalid pixman buffer and hit the following assertion when trying to render to it: --- render/picture.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/render/picture.c +++ b/render/picture.c @@ -762,6 +762,7 @@ CreatePicture(Picture pid, { PicturePtr pPicture; PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen); + int bpp; pPicture = dixAllocateScreenObjectWithPrivates(pDrawable->pScreen, PictureRec, PRIVATE_PICTURE); @@ -773,7 +774,10 @@ CreatePicture(Picture pid, pPicture->id = pid; pPicture->pDrawable = pDrawable; pPicture->pFormat = pFormat; - pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24); + bpp = pDrawable->bitsPerPixel; + if (bpp < pFormat->depth) + bpp = BitsPerPixel (pFormat->depth); + pPicture->format = pFormat->format | (bpp << 24); /* security creation/labeling check */ *error = XaceHook(XACE_RESOURCE_ACCESS, client, pid, PictureType, pPicture,