summaryrefslogtreecommitdiff
path: root/src/amdgpu_dri2.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2018-05-17 09:50:50 +0200
committerMichel Dänzer <michel@daenzer.net>2018-07-10 18:09:34 +0200
commitc160302abcdb18eec35c377d80e34f5bd857df45 (patch)
tree9e7379a38c6abb028af70e04ff6f3b1e7313bd89 /src/amdgpu_dri2.c
parent61040bdfa360975614fb47aa7ea1b3a1abac3427 (diff)
Bail from dri2_create_buffer2 if we can't get a pixmap
We would store the NULL pointer and continue, which would lead to a crash down the road. Bugzilla: https://bugs.freedesktop.org/106293 (Ported from radeon commit 3dcfce8d0f495d09d7836caf98ef30d625b78a13) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src/amdgpu_dri2.c')
-rw-r--r--src/amdgpu_dri2.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index a9e2819..a9238e5 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -161,29 +161,28 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
AMDGPU_CREATE_PIXMAP_DRI2);
}
+ if (!pixmap)
+ return NULL;
+
buffers = calloc(1, sizeof *buffers);
if (!buffers)
goto error;
- if (pixmap) {
- if (is_glamor_pixmap) {
- pixmap = amdgpu_glamor_set_pixmap_bo(drawable, pixmap);
- pixmap->refcnt++;
- }
-
- if (!amdgpu_get_flink_name(pAMDGPUEnt, pixmap, &buffers->name))
- goto error;
+ if (is_glamor_pixmap) {
+ pixmap = amdgpu_glamor_set_pixmap_bo(drawable, pixmap);
+ pixmap->refcnt++;
}
+ if (!amdgpu_get_flink_name(pAMDGPUEnt, pixmap, &buffers->name))
+ goto error;
+
privates = calloc(1, sizeof(struct dri2_buffer_priv));
if (!privates)
goto error;
buffers->attachment = attachment;
- if (pixmap) {
- buffers->pitch = pixmap->devKind;
- buffers->cpp = cpp;
- }
+ buffers->pitch = pixmap->devKind;
+ buffers->cpp = cpp;
buffers->driverPrivate = privates;
buffers->format = format;
buffers->flags = 0; /* not tiled */
@@ -195,8 +194,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
error:
free(buffers);
- if (pixmap)
- (*pScreen->DestroyPixmap) (pixmap);
+ (*pScreen->DestroyPixmap) (pixmap);
return NULL;
}