summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2017-02-02 18:40:18 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2017-03-14 00:13:14 +0000
commit346081e7ad244c51922480a04df711ebf473784f (patch)
treee49fae0dd1d0ea23f7947a50bd72af9c8473ebbe /src
parenteca9916254b9525985f5e551459ffdde8b7bd0c8 (diff)
winsys/amdgpu: avoid potential segfault in amdgpu_bo_map()
cs can be NULL when it comes from r600_buffer_map_sync_with_rings() to avoid doing the same checks. It was checked for write mappings but not for read mappings. Cc: "17.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> (cherry picked from commit af303abcdbeac3b90fb760de19bed56cc40cfff4)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index e8d2c006f36..e7ea51978ee 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -253,14 +253,17 @@ static void *amdgpu_bo_map(struct pb_buffer *buf,
* (neither one is changing it).
*
* Only check whether the buffer is being used for write. */
- if (cs && amdgpu_bo_is_referenced_by_cs_with_usage(cs, bo,
- RADEON_USAGE_WRITE)) {
- cs->flush_cs(cs->flush_data, 0, NULL);
- } else {
- /* Try to avoid busy-waiting in amdgpu_bo_wait. */
- if (p_atomic_read(&bo->num_active_ioctls))
- amdgpu_cs_sync_flush(rcs);
+ if (cs) {
+ if (amdgpu_bo_is_referenced_by_cs_with_usage(cs, bo,
+ RADEON_USAGE_WRITE)) {
+ cs->flush_cs(cs->flush_data, 0, NULL);
+ } else {
+ /* Try to avoid busy-waiting in amdgpu_bo_wait. */
+ if (p_atomic_read(&bo->num_active_ioctls))
+ amdgpu_cs_sync_flush(rcs);
+ }
}
+
amdgpu_bo_wait((struct pb_buffer*)bo, PIPE_TIMEOUT_INFINITE,
RADEON_USAGE_WRITE);
} else {