]> git.openfabrics.org - ~shefty/rdma-dev.git/blobdiff - drivers/gpu/drm/radeon/radeon_ring.c
drm/radeon: prevent crash in the ring space allocation
[~shefty/rdma-dev.git] / drivers / gpu / drm / radeon / radeon_ring.c
index 2430d80b18716b6cd8c338c6fff86c53354992ac..cd72062d5a9134bd596c8a6388b78fd45bb02425 100644 (file)
@@ -377,6 +377,9 @@ int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *ring, unsi
 {
        int r;
 
+       /* make sure we aren't trying to allocate more space than there is on the ring */
+       if (ndw > (ring->ring_size / 4))
+               return -ENOMEM;
        /* Align requested size with padding so unlock_commit can
         * pad safely */
        ndw = (ndw + ring->align_mask) & ~ring->align_mask;