]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
radeon/kms: fix dma relocation checking
authorJerome Glisse <jglisse@redhat.com>
Wed, 9 Jan 2013 21:40:42 +0000 (16:40 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 10 Jan 2013 22:05:38 +0000 (17:05 -0500)
We were checking the index against the size of the relocation buffer
instead of against the last index. This fix kernel segfault when
userspace submit ill formated command stream/relocation buffer pair.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/r600_cs.c

index 6858a4068f7bd2fb18309025644d0c2944aa7a50..69ec24ab8d636453dfa7e2ab313588786341c977 100644 (file)
@@ -2563,16 +2563,16 @@ int r600_dma_cs_next_reloc(struct radeon_cs_parser *p,
        struct radeon_cs_chunk *relocs_chunk;
        unsigned idx;
 
+       *cs_reloc = NULL;
        if (p->chunk_relocs_idx == -1) {
                DRM_ERROR("No relocation chunk !\n");
                return -EINVAL;
        }
-       *cs_reloc = NULL;
        relocs_chunk = &p->chunks[p->chunk_relocs_idx];
        idx = p->dma_reloc_idx;
-       if (idx >= relocs_chunk->length_dw) {
+       if (idx >= p->nrelocs) {
                DRM_ERROR("Relocs at %d after relocations chunk end %d !\n",
-                         idx, relocs_chunk->length_dw);
+                         idx, p->nrelocs);
                return -EINVAL;
        }
        *cs_reloc = p->relocs_ptr[idx];