diff options
author | Samuel Pitoiset <[email protected]> | 2017-02-02 18:40:18 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-02-08 14:30:50 +0000 |
commit | f02f17f133d7f979215d8bf6fc33e2c97f17457b (patch) | |
tree | 2466252a3764158a17ae7091451e7d52127fc5ff /src | |
parent | d4f1ed62158e69a028e84d9ebc1b642be5bf0e07 (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" <[email protected]>
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
(cherry picked from commit af303abcdbeac3b90fb760de19bed56cc40cfff4)
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 17 |
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 { |