summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2015-08-28 14:50:21 -0400
committerEmil Velikov <emil.l.velikov@gmail.com>2015-09-23 21:02:07 +0100
commitbcb3bfd5101f2f930fd91a7c7bbd050172d16572 (patch)
tree905dc9d68130d55d11d67257746e647e27967ac2
parentebfa2ea34fd213b1395db7f9741d7cc181b2c415 (diff)
gbm: convert gbm bo format to fourcc format on dma-buf import
At the moment if a gbm buffer is imported and the gbm buffer has an old-style GBM_BO_FORMAT format, the import will crash, since it's passed directly to DRI functions that expect a fourcc format (as provided by the newer GBM_FORMAT definitions) This commit addresses the problem in two ways: 1) it prevents invalid formats from leading to a crash by returning EINVAL if the image couldn't be created 2) it translates GBM_BO_FORMAT formats into the comparable GBM_FORMAT formats. Reference: https://bugzilla.gnome.org/show_bug.cgi?id=753531 CC: "10.6 11.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> (cherry picked from commit 4bf151e66279da00655cec02aadb52c9c6583213)
-rw-r--r--src/gbm/backends/dri/gbm_dri.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index ccc3cc6930f..57cdeacdccd 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -706,14 +706,30 @@ gbm_dri_bo_import(struct gbm_device *gbm,
{
struct gbm_import_fd_data *fd_data = buffer;
int stride = fd_data->stride, offset = 0;
+ int dri_format;
+
+ switch (fd_data->format) {
+ case GBM_BO_FORMAT_XRGB8888:
+ dri_format = GBM_FORMAT_XRGB8888;
+ break;
+ case GBM_BO_FORMAT_ARGB8888:
+ dri_format = GBM_FORMAT_ARGB8888;
+ break;
+ default:
+ dri_format = fd_data->format;
+ }
image = dri->image->createImageFromFds(dri->screen,
fd_data->width,
fd_data->height,
- fd_data->format,
+ dri_format,
&fd_data->fd, 1,
&stride, &offset,
NULL);
+ if (image == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
gbm_format = fd_data->format;
break;
}