diff options
author | Alex Ivanov <gnidorah@p0n4ik.tk> | 2013-09-20 09:36:06 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2013-09-20 17:34:52 -0400 |
commit | 0eb3448aa6b31fbf24c31756aba7940cac5ad6b8 (patch) | |
tree | 0ca178740172d26985af7ddf8325e85a544835be /drivers/gpu/drm/radeon/radeon_ring.c | |
parent | 42baf21d91d4f52f5b9a4d11dc8e7b1e3b93de7c (diff) |
drm/radeon: Make r100_cp_ring_info() and radeon_ring_gfx() safe (v2)
Prevent NULL pointer dereference in case when radeon_ring_fini() did it's job.
Reading of r100_cp_ring_info and radeon_ring_gfx debugfs entries will lead to a KP if ring buffer was deallocated, e.g. on failed ring test.
Seen on PA-RISC machine having "radeon: ring test failed (scratch(0x8504)=0xCAFEDEAD)" issue.
v2: agd5f: add some parens around ring->ready check
Signed-off-by: Alex Ivanov <gnidorah@p0n4ik.tk>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_ring.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ring.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index 46a25f037b84..18254e1c3e71 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c | |||
@@ -839,9 +839,11 @@ static int radeon_debugfs_ring_info(struct seq_file *m, void *data) | |||
839 | * packet that is the root issue | 839 | * packet that is the root issue |
840 | */ | 840 | */ |
841 | i = (ring->rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask; | 841 | i = (ring->rptr + ring->ptr_mask + 1 - 32) & ring->ptr_mask; |
842 | for (j = 0; j <= (count + 32); j++) { | 842 | if (ring->ready) { |
843 | seq_printf(m, "r[%5d]=0x%08x\n", i, ring->ring[i]); | 843 | for (j = 0; j <= (count + 32); j++) { |
844 | i = (i + 1) & ring->ptr_mask; | 844 | seq_printf(m, "r[%5d]=0x%08x\n", i, ring->ring[i]); |
845 | i = (i + 1) & ring->ptr_mask; | ||
846 | } | ||
845 | } | 847 | } |
846 | return 0; | 848 | return 0; |
847 | } | 849 | } |